From 8ba22a248118dfd5869adc9da881794e464e564c Mon Sep 17 00:00:00 2001 From: tusooa Date: Fri, 9 Jun 2023 16:11:15 -0400 Subject: [PATCH] Fix react button not working if reaction accounts are not loaded --- changelog.d/react-button.fix | 1 + src/components/emoji_reactions/emoji_reactions.js | 7 ++++--- src/modules/statuses.js | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 changelog.d/react-button.fix diff --git a/changelog.d/react-button.fix b/changelog.d/react-button.fix new file mode 100644 index 00000000..c2222fb6 --- /dev/null +++ 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 index b4936424..4d5c6c5a 100644 --- 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 index 93a4a957..ed21a730 100644 --- 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 }) }