From d0075026290c90d8406c7ac81413259a8ae58ec7 Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Fri, 15 Nov 2019 08:39:21 +0200 Subject: [PATCH 01/33] 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, From de945ba3e9470b28dd010fb32f658b42053f19d3 Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Fri, 15 Nov 2019 16:29:25 +0200 Subject: [PATCH 02/33] wip commit, add basic popover for emoji reaction select --- src/components/react_button/react_button.js | 50 +++++++++++++ src/components/react_button/react_button.vue | 78 ++++++++++++++++++++ src/components/status/status.js | 2 + src/components/status/status.vue | 10 ++- src/i18n/en.json | 1 + 5 files changed, 138 insertions(+), 3 deletions(-) create mode 100644 src/components/react_button/react_button.js create mode 100644 src/components/react_button/react_button.vue diff --git a/src/components/react_button/react_button.js b/src/components/react_button/react_button.js new file mode 100644 index 0000000000..d1d15d930b --- /dev/null +++ b/src/components/react_button/react_button.js @@ -0,0 +1,50 @@ +import { mapGetters } from 'vuex' + +const ReactButton = { + props: ['status', 'loggedIn'], + data () { + return { + animated: false, + showTooltip: false, + popperOptions: { + modifiers: { + preventOverflow: { padding: { top: 50 }, boundariesElement: 'viewport' } + } + } + } + }, + methods: { + openReactionSelect () { + console.log('test') + this.showTooltip = true + }, + closeReactionSelect () { + this.showTooltip = false + }, + favorite () { + if (!this.status.favorited) { + this.$store.dispatch('favorite', { id: this.status.id }) + } else { + this.$store.dispatch('unfavorite', { id: this.status.id }) + } + this.animated = true + setTimeout(() => { + this.animated = false + }, 500) + } + }, + computed: { + emojis () { + return this.$store.state.instance.emoji || [] + }, + classes () { + return { + 'icon-smile': true, + 'animate-spin': this.animated + } + }, + ...mapGetters(['mergedConfig']) + } +} + +export default ReactButton diff --git a/src/components/react_button/react_button.vue b/src/components/react_button/react_button.vue new file mode 100644 index 0000000000..936387702a --- /dev/null +++ b/src/components/react_button/react_button.vue @@ -0,0 +1,78 @@ + + + + + diff --git a/src/components/status/status.js b/src/components/status/status.js index 8268e615a0..8c6fc0cf74 100644 --- a/src/components/status/status.js +++ b/src/components/status/status.js @@ -1,5 +1,6 @@ import Attachment from '../attachment/attachment.vue' import FavoriteButton from '../favorite_button/favorite_button.vue' +import ReactButton from '../react_button/react_button.vue' import RetweetButton from '../retweet_button/retweet_button.vue' import Poll from '../poll/poll.vue' import ExtraButtons from '../extra_buttons/extra_buttons.vue' @@ -289,6 +290,7 @@ const Status = { components: { Attachment, FavoriteButton, + ReactButton, RetweetButton, ExtraButtons, PostStatusForm, diff --git a/src/components/status/status.vue b/src/components/status/status.vue index aae58a5ed3..d455ccf692 100644 --- a/src/components/status/status.vue +++ b/src/components/status/status.vue @@ -356,12 +356,12 @@
@@ -393,6 +393,10 @@ :logged-in="loggedIn" :status="status" /> + Date: Tue, 10 Dec 2019 23:54:28 +0900 Subject: [PATCH 03/33] fix parse for move type notifications --- src/i18n/en.json | 3 ++- src/modules/statuses.js | 5 ++++- src/services/entity_normalizer/entity_normalizer.service.js | 5 ++++- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/i18n/en.json b/src/i18n/en.json index 85146ef577..f46d5b3df2 100644 --- a/src/i18n/en.json +++ b/src/i18n/en.json @@ -110,7 +110,8 @@ "notifications": "Notifications", "read": "Read!", "repeated_you": "repeated your status", - "no_more_notifications": "No more notifications" + "no_more_notifications": "No more notifications", + "moved_to": "moved to" }, "polls": { "add_poll": "Add Poll", diff --git a/src/modules/statuses.js b/src/modules/statuses.js index f11ffdcdc3..3cf74a43d4 100644 --- a/src/modules/statuses.js +++ b/src/modules/statuses.js @@ -305,7 +305,7 @@ const addNewStatuses = (state, { statuses, showImmediately = false, timeline, us const addNewNotifications = (state, { dispatch, notifications, older, visibleNotificationTypes, rootGetters }) => { each(notifications, (notification) => { - if (notification.type !== 'follow') { + if (notification.type !== 'follow' && notification.type !== 'move') { notification.action = addStatusToGlobalStorage(state, notification.action).item notification.status = notification.status && addStatusToGlobalStorage(state, notification.status).item } @@ -338,6 +338,9 @@ const addNewNotifications = (state, { dispatch, notifications, older, visibleNot case 'follow': i18nString = 'followed_you' break + case 'move': + i18nString = 'moved_to' + break } if (i18nString) { diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index ca79df6f6f..ee007bee12 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -341,10 +341,13 @@ export const parseNotification = (data) => { if (masto) { output.type = mastoDict[data.type] || data.type output.seen = data.pleroma.is_seen - output.status = output.type === 'follow' + output.status = output.type === 'follow' || output.type === 'move' ? null : parseStatus(data.status) output.action = output.status // TODO: Refactor, this is unneeded + output.target = output.type !== 'move' + ? null + : parseUser(data.target) output.from_profile = parseUser(data.account) } else { const parsedNotice = parseStatus(data.notice) From 6af870cd9069a8fc45b7684d264656dad0cf4a70 Mon Sep 17 00:00:00 2001 From: kPherox Date: Wed, 11 Dec 2019 00:00:10 +0900 Subject: [PATCH 04/33] Add view for moves notifications --- src/components/notification/notification.vue | 14 +++++++++++++- src/components/notifications/notifications.scss | 7 ++++++- src/components/settings/settings.vue | 5 +++++ src/i18n/en.json | 1 + src/modules/config.js | 3 ++- src/modules/statuses.js | 3 ++- .../notification_utils/notification_utils.js | 3 ++- src/services/push/push.js | 3 ++- static/fontello.json | 6 ++++++ 9 files changed, 39 insertions(+), 6 deletions(-) diff --git a/src/components/notification/notification.vue b/src/components/notification/notification.vue index 1f192c7709..cf4d8072f2 100644 --- a/src/components/notification/notification.vue +++ b/src/components/notification/notification.vue @@ -74,9 +74,13 @@ {{ $t('notifications.followed_you') }} + + + {{ $t('notifications.moved_to') }} +
@@ -115,6 +119,14 @@ @{{ notification.from_profile.screen_name }}
+
+ + @{{ notification.target.screen_name }} + +
@@ -31,10 +31,10 @@ align-items: center; justify-content: center; box-sizing: border-box; - :first-child { + &:first-child { margin-right: 0.25em; } - :last-child { + &:last-child { width: 1.5em; } &:focus { diff --git a/src/components/react_button/react_button.js b/src/components/react_button/react_button.js index d1a179bc4c..6fb2a78027 100644 --- a/src/components/react_button/react_button.js +++ b/src/components/react_button/react_button.js @@ -4,7 +4,6 @@ const ReactButton = { props: ['status', 'loggedIn'], data () { return { - animated: false, showTooltip: false, filterWord: '', popperOptions: { @@ -29,7 +28,7 @@ const ReactButton = { }, computed: { commonEmojis () { - return ['💖', '😠', '👀', '😂', '🔥'] + return ['❤️', '😠', '👀', '😂', '🔥'] }, emojis () { if (this.filterWord !== '') { @@ -37,12 +36,6 @@ const ReactButton = { } return this.$store.state.instance.emoji || [] }, - classes () { - return { - 'icon-smile': true, - 'animate-spin': this.animated - } - }, ...mapGetters(['mergedConfig']) } } diff --git a/src/components/react_button/react_button.vue b/src/components/react_button/react_button.vue index 7f1bc4926c..c925dd7187 100644 --- a/src/components/react_button/react_button.vue +++ b/src/components/react_button/react_button.vue @@ -40,8 +40,7 @@ @click.prevent="openReactionSelect" > diff --git a/src/services/entity_normalizer/entity_normalizer.service.js b/src/services/entity_normalizer/entity_normalizer.service.js index f66d09ac1d..a3d0b78278 100644 --- a/src/services/entity_normalizer/entity_normalizer.service.js +++ b/src/services/entity_normalizer/entity_normalizer.service.js @@ -233,7 +233,6 @@ export const parseStatus = (data) => { output.statusnet_html = addEmojis(data.content, data.emojis) output.tags = data.tags - output.emoji_reactions = data.pleroma.emoji_reactions if (data.pleroma) { const { pleroma } = data @@ -243,6 +242,7 @@ export const parseStatus = (data) => { output.is_local = pleroma.local output.in_reply_to_screen_name = data.pleroma.in_reply_to_account_acct output.thread_muted = pleroma.thread_muted + output.emoji_reactions = pleroma.emoji_reactions } else { output.text = data.content output.summary = data.spoiler_text From 29806c962972091cda2c7d55380b3326b5a07ba4 Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Tue, 28 Jan 2020 17:53:47 +0200 Subject: [PATCH 32/33] fix emoji reaction classes broken in develop --- src/components/emoji_reactions/emoji_reactions.vue | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/components/emoji_reactions/emoji_reactions.vue b/src/components/emoji_reactions/emoji_reactions.vue index 741fc11eaf..00d6d2b7ac 100644 --- a/src/components/emoji_reactions/emoji_reactions.vue +++ b/src/components/emoji_reactions/emoji_reactions.vue @@ -7,7 +7,7 @@ :class="{ 'picked-reaction': reactedWith(reaction.emoji) }" @click="emojiOnClick(reaction.emoji, $event)" > - {{ reaction.emoji }} + {{ reaction.emoji }} {{ reaction.count }} @@ -31,12 +31,10 @@ align-items: center; justify-content: center; box-sizing: border-box; - &:first-child { + .reaction-emoji { + width: 1.25em; margin-right: 0.25em; } - &:last-child { - width: 1.5em; - } &:focus { outline: none; } From c54111797ae1058e59931b2d1f12e6ab6a6f96a9 Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Tue, 28 Jan 2020 17:54:40 +0200 Subject: [PATCH 33/33] add emoji reactions to changelog --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b09eb3a046..65973dbbe3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Support for 'Move' type notifications - Pleroma AMOLED dark theme - User level domain mutes, under User Settings -> Mutes +- Emoji reactions for statuses ### Changed - Captcha now resets on failed registrations - Notifications column now cleans itself up to optimize performance when tab is left open for a long time