fix "who reacted" emoji display

fixes #80
This commit is contained in:
FloatingGhost 2022-08-11 18:14:05 +01:00
parent edf36d28ca
commit cbf883ab1e
3 changed files with 31 additions and 16 deletions

View file

@ -27,7 +27,11 @@ const EmojiReactions = {
}, },
accountsForEmoji () { accountsForEmoji () {
return this.status.emoji_reactions.reduce((acc, reaction) => { return this.status.emoji_reactions.reduce((acc, reaction) => {
if (reaction.url) {
acc[reaction.url] = reaction.accounts || []
} else {
acc[reaction.name] = reaction.accounts || [] acc[reaction.name] = reaction.accounts || []
}
return acc return acc
}, {}) }, {})
}, },
@ -42,6 +46,14 @@ 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
}, },
isLocalReaction (emojiUrl) {
if (!emojiUrl) return true
const reacted = this.accountsForEmoji[emojiUrl]
if (reacted.length === 0) {
return true
}
return reacted[0].is_local
},
fetchEmojiReactionsByIfMissing () { 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) {

View file

@ -2,12 +2,13 @@
<div class="emoji-reactions"> <div class="emoji-reactions">
<UserListPopover <UserListPopover
v-for="(reaction) in emojiReactions" v-for="(reaction) in emojiReactions"
:key="reaction.name" :key="reaction.url || reaction.name"
:users="accountsForEmoji[reaction.name]" :users="accountsForEmoji[reaction.url || reaction.name]"
> >
<button <button
class="emoji-reaction btn button-default" class="emoji-reaction btn button-default"
:class="{ 'picked-reaction': reactedWith(reaction.name), 'not-clickable': !loggedIn }" :class="{ 'picked-reaction': reactedWith(reaction.name), 'not-clickable': !loggedIn }"
:disabled="!isLocalReaction(reaction.url)"
@click="emojiOnClick(reaction.name, $event)" @click="emojiOnClick(reaction.name, $event)"
@mouseenter="fetchEmojiReactionsByIfMissing()" @mouseenter="fetchEmojiReactionsByIfMissing()"
> >

View file

@ -148,6 +148,7 @@ export default {
mfmHtml.innerHTML = marked.parse(content) mfmHtml.innerHTML = marked.parse(content)
// Add options with set values to CSS // Add options with set values to CSS
if (mfmHtml.content.firstChild) {
Array.from(mfmHtml.content.firstChild.getElementsByClassName('mfm')).map((el) => { Array.from(mfmHtml.content.firstChild.getElementsByClassName('mfm')).map((el) => {
if (el.dataset.speed) { if (el.dataset.speed) {
el.style.animationDuration = el.dataset.speed el.style.animationDuration = el.dataset.speed
@ -162,6 +163,7 @@ export default {
} }
} }
}) })
}
return mfmHtml.innerHTML return mfmHtml.innerHTML
} }