Fix react button not working if reaction accounts are not loaded

このコミットが含まれているのは:
tusooa 2023-06-09 16:11:15 -04:00
コミット 8ba22a2481
この署名に対応する既知のキーがデータベースに存在しません
GPGキーID: 42AEC43D48433C51
3個のファイルの変更6行の追加4行の削除

1
changelog.d/react-button.fix ノーマルファイル
ファイルの表示

@ -0,0 +1 @@
Fix react button not working if reaction accounts are not loaded

ファイルの表示

@ -57,10 +57,10 @@ const EmojiReactions = {
reactedWith (emoji) { reactedWith (emoji) {
return this.status.emoji_reactions.find(r => r.name === emoji).me return this.status.emoji_reactions.find(r => r.name === emoji).me
}, },
fetchEmojiReactionsByIfMissing () { async fetchEmojiReactionsByIfMissing () {
const hasNoAccounts = this.status.emoji_reactions.find(r => !r.accounts) const hasNoAccounts = this.status.emoji_reactions.find(r => !r.accounts)
if (hasNoAccounts) { if (hasNoAccounts) {
this.$store.dispatch('fetchEmojiReactionsBy', this.status.id) return await this.$store.dispatch('fetchEmojiReactionsBy', this.status.id)
} }
}, },
reactWith (emoji) { reactWith (emoji) {
@ -69,9 +69,10 @@ const EmojiReactions = {
unreact (emoji) { unreact (emoji) {
this.$store.dispatch('unreactWithEmoji', { id: this.status.id, emoji }) this.$store.dispatch('unreactWithEmoji', { id: this.status.id, emoji })
}, },
emojiOnClick (emoji, event) { async emojiOnClick (emoji, event) {
if (!this.loggedIn) return if (!this.loggedIn) return
await this.fetchEmojiReactionsByIfMissing()
if (this.reactedWith(emoji)) { if (this.reactedWith(emoji)) {
this.unreact(emoji) this.unreact(emoji)
} else { } else {

ファイルの表示

@ -757,7 +757,7 @@ const statuses = {
) )
}, },
fetchEmojiReactionsBy ({ rootState, commit }, id) { fetchEmojiReactionsBy ({ rootState, commit }, id) {
rootState.api.backendInteractor.fetchEmojiReactions({ id }).then( return rootState.api.backendInteractor.fetchEmojiReactions({ id }).then(
emojiReactions => { emojiReactions => {
commit('addEmojiReactionsBy', { id, emojiReactions, currentUser: rootState.users.currentUser }) commit('addEmojiReactionsBy', { id, emojiReactions, currentUser: rootState.users.currentUser })
} }