From d0075026290c90d8406c7ac81413259a8ae58ec7 Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Fri, 15 Nov 2019 08:39:21 +0200 Subject: [PATCH] add fetching for emoji reactions, draft design --- src/components/conversation/conversation.js | 1 + src/components/status/status.js | 6 ++++ src/components/status/status.vue | 28 +++++++++++++++++++ src/modules/statuses.js | 14 +++++++++- src/services/api/api.service.js | 6 ++++ .../backend_interactor_service.js | 2 ++ 6 files changed, 56 insertions(+), 1 deletion(-) diff --git a/src/components/conversation/conversation.js b/src/components/conversation/conversation.js index 72ee9c390d..715804ff9c 100644 --- a/src/components/conversation/conversation.js +++ b/src/components/conversation/conversation.js @@ -149,6 +149,7 @@ const conversation = { if (!id) return this.highlight = id this.$store.dispatch('fetchFavsAndRepeats', id) + this.$store.dispatch('fetchEmojiReactions', id) }, getHighlight () { return this.isExpanded ? this.highlight : null diff --git a/src/components/status/status.js b/src/components/status/status.js index 4fbd5ac3e0..8268e615a0 100644 --- a/src/components/status/status.js +++ b/src/components/status/status.js @@ -278,6 +278,12 @@ const Status = { hidePostStats () { return this.mergedConfig.hidePostStats }, + emojiReactions () { + return { + '🤔': [{ 'id': 'xyz..' }, { 'id': 'zyx...' }], + '🐻': [{ 'id': 'abc...' }] + } + }, ...mapGetters(['mergedConfig']) }, components: { diff --git a/src/components/status/status.vue b/src/components/status/status.vue index 65778b2e5d..aae58a5ed3 100644 --- a/src/components/status/status.vue +++ b/src/components/status/status.vue @@ -354,6 +354,17 @@ +
+ +
+
currentUser.id === id) }, + addEmojiReactions (state, { id, emojiReactions, currentUser }) { + const status = state.allStatusesObject[id] + status.emojiReactions = emojiReactions + status.reactedWithEmoji = findKey(emojiReactions, { id: currentUser.id }) + }, updateStatusWithPoll (state, { id, poll }) { const status = state.allStatusesObject[id] status.poll = poll @@ -611,6 +616,13 @@ const statuses = { commit('addRepeats', { id, rebloggedByUsers, currentUser: rootState.users.currentUser }) }) }, + fetchEmojiReactions ({ rootState, commit }, id) { + rootState.api.backendInteractor.fetchEmojiReactions(id).then( + emojiReactions => { + commit('addEmojiReactions', { id, emojiReactions, currentUser: rootState.users.currentUser }) + } + ) + }, fetchFavs ({ rootState, commit }, id) { rootState.api.backendInteractor.fetchFavoritedByUsers(id) .then(favoritedByUsers => commit('addFavs', { id, favoritedByUsers, currentUser: rootState.users.currentUser })) diff --git a/src/services/api/api.service.js b/src/services/api/api.service.js index 8f5eb4163a..7ef4b74a2b 100644 --- a/src/services/api/api.service.js +++ b/src/services/api/api.service.js @@ -71,6 +71,7 @@ const MASTODON_MUTE_CONVERSATION = id => `/api/v1/statuses/${id}/mute` const MASTODON_UNMUTE_CONVERSATION = id => `/api/v1/statuses/${id}/unmute` const MASTODON_SEARCH_2 = `/api/v2/search` const MASTODON_USER_SEARCH_URL = '/api/v1/accounts/search' +const PLEROMA_EMOJI_REACTIONS_URL = id => `/api/v1/pleroma/statuses/${id}/emoji_reactions_by` const oldfetch = window.fetch @@ -864,6 +865,10 @@ const fetchRebloggedByUsers = ({ id }) => { return promisedRequest({ url: MASTODON_STATUS_REBLOGGEDBY_URL(id) }).then((users) => users.map(parseUser)) } +const fetchEmojiReactions = ({ id }) => { + return promisedRequest({ url: PLEROMA_EMOJI_REACTIONS_URL(id) }) +} + const reportUser = ({ credentials, userId, statusIds, comment, forward }) => { return promisedRequest({ url: MASTODON_REPORT_USER_URL, @@ -997,6 +1002,7 @@ const apiService = { fetchPoll, fetchFavoritedByUsers, fetchRebloggedByUsers, + fetchEmojiReactions, reportUser, updateNotificationSettings, search2, diff --git a/src/services/backend_interactor_service/backend_interactor_service.js b/src/services/backend_interactor_service/backend_interactor_service.js index d6617276d9..52234fcc77 100644 --- a/src/services/backend_interactor_service/backend_interactor_service.js +++ b/src/services/backend_interactor_service/backend_interactor_service.js @@ -143,6 +143,7 @@ const backendInteractorService = credentials => { const fetchFavoritedByUsers = (id) => apiService.fetchFavoritedByUsers({ id }) const fetchRebloggedByUsers = (id) => apiService.fetchRebloggedByUsers({ id }) + const fetchEmojiReactions = (id) => apiService.fetchEmojiReactions({ id }) const reportUser = (params) => apiService.reportUser({ credentials, ...params }) const favorite = (id) => apiService.favorite({ id, credentials }) @@ -210,6 +211,7 @@ const backendInteractorService = credentials => { fetchPoll, fetchFavoritedByUsers, fetchRebloggedByUsers, + fetchEmojiReactions, reportUser, favorite, unfavorite,