logo

pleroma-fe

My custom branche(s) on git.pleroma.social/pleroma/pleroma-fe git clone https://hacktivis.me/git/pleroma-fe.git
commit: 5b93e4a0ded16d03db45f2e05ec9e4546d42fb36
parent 624af7ed00b0edb2792f84cc83f6eeb7568798c4
Author: HJ <30-hj@users.noreply.git.pleroma.social>
Date:   Sat, 10 Jun 2023 23:19:14 +0000

Merge branch 'tusooa/react-button-fix' into 'develop'

Fix react button not working if reaction accounts are not loaded

See merge request pleroma/pleroma-fe!1837

Diffstat:

Achangelog.d/react-button.fix1+
Msrc/components/emoji_reactions/emoji_reactions.js7++++---
Msrc/modules/statuses.js2+-
3 files changed, 6 insertions(+), 4 deletions(-)

diff --git a/changelog.d/react-button.fix b/changelog.d/react-button.fix @@ -0,0 +1 @@ +Fix react button not working if reaction accounts are not loaded diff --git a/src/components/emoji_reactions/emoji_reactions.js b/src/components/emoji_reactions/emoji_reactions.js @@ -57,10 +57,10 @@ const EmojiReactions = { reactedWith (emoji) { return this.status.emoji_reactions.find(r => r.name === emoji).me }, - fetchEmojiReactionsByIfMissing () { + async fetchEmojiReactionsByIfMissing () { const hasNoAccounts = this.status.emoji_reactions.find(r => !r.accounts) if (hasNoAccounts) { - this.$store.dispatch('fetchEmojiReactionsBy', this.status.id) + return await this.$store.dispatch('fetchEmojiReactionsBy', this.status.id) } }, reactWith (emoji) { @@ -69,9 +69,10 @@ const EmojiReactions = { unreact (emoji) { this.$store.dispatch('unreactWithEmoji', { id: this.status.id, emoji }) }, - emojiOnClick (emoji, event) { + async emojiOnClick (emoji, event) { if (!this.loggedIn) return + await this.fetchEmojiReactionsByIfMissing() if (this.reactedWith(emoji)) { this.unreact(emoji) } else { diff --git a/src/modules/statuses.js b/src/modules/statuses.js @@ -757,7 +757,7 @@ const statuses = { ) }, fetchEmojiReactionsBy ({ rootState, commit }, id) { - rootState.api.backendInteractor.fetchEmojiReactions({ id }).then( + return rootState.api.backendInteractor.fetchEmojiReactions({ id }).then( emojiReactions => { commit('addEmojiReactionsBy', { id, emojiReactions, currentUser: rootState.users.currentUser }) }