forked from AkkomaGang/akkoma-fe
parent
edf36d28ca
commit
cbf883ab1e
3 changed files with 31 additions and 16 deletions
|
@ -27,7 +27,11 @@ const EmojiReactions = {
|
|||
},
|
||||
accountsForEmoji () {
|
||||
return this.status.emoji_reactions.reduce((acc, reaction) => {
|
||||
if (reaction.url) {
|
||||
acc[reaction.url] = reaction.accounts || []
|
||||
} else {
|
||||
acc[reaction.name] = reaction.accounts || []
|
||||
}
|
||||
return acc
|
||||
}, {})
|
||||
},
|
||||
|
@ -42,6 +46,14 @@ const EmojiReactions = {
|
|||
reactedWith (emoji) {
|
||||
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 () {
|
||||
const hasNoAccounts = this.status.emoji_reactions.find(r => !r.accounts)
|
||||
if (hasNoAccounts) {
|
||||
|
|
|
@ -2,12 +2,13 @@
|
|||
<div class="emoji-reactions">
|
||||
<UserListPopover
|
||||
v-for="(reaction) in emojiReactions"
|
||||
:key="reaction.name"
|
||||
:users="accountsForEmoji[reaction.name]"
|
||||
:key="reaction.url || reaction.name"
|
||||
:users="accountsForEmoji[reaction.url || reaction.name]"
|
||||
>
|
||||
<button
|
||||
class="emoji-reaction btn button-default"
|
||||
:class="{ 'picked-reaction': reactedWith(reaction.name), 'not-clickable': !loggedIn }"
|
||||
:disabled="!isLocalReaction(reaction.url)"
|
||||
@click="emojiOnClick(reaction.name, $event)"
|
||||
@mouseenter="fetchEmojiReactionsByIfMissing()"
|
||||
>
|
||||
|
|
|
@ -148,6 +148,7 @@ export default {
|
|||
mfmHtml.innerHTML = marked.parse(content)
|
||||
|
||||
// Add options with set values to CSS
|
||||
if (mfmHtml.content.firstChild) {
|
||||
Array.from(mfmHtml.content.firstChild.getElementsByClassName('mfm')).map((el) => {
|
||||
if (el.dataset.speed) {
|
||||
el.style.animationDuration = el.dataset.speed
|
||||
|
@ -162,6 +163,7 @@ export default {
|
|||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
return mfmHtml.innerHTML
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue