fix reactions but actually this time

This commit is contained in:
CoolElectronics 2024-06-11 17:22:25 -04:00
parent 8a17e3f95e
commit 54b440b9f5
No known key found for this signature in database
GPG key ID: F63593D168636C50
5 changed files with 49 additions and 37 deletions

View file

@ -9,7 +9,6 @@
class="emoji-reaction btn button-default"
:class="{ 'picked-reaction': reactedWith(reaction.name), 'not-clickable': !loggedIn }"
@click="emojiOnClick(reaction.name, $event)"
@mouseenter="fetchEmojiReactionsByIfMissing()"
>
<span
v-if="reaction.url !== null"

View file

@ -564,33 +564,45 @@ const Status = {
},
async mounted () {
if (this.status.refetched) return;
let data = await fetch("/api/notes/show", {
"headers": {
"Content-Type": "application/json",
},
"referrer": "https://grimgreenfo.rest/",
"body": JSON.stringify({ "noteId": this.status.id, i: "JEg68SCqcTaFpvF5" }),
"method": "POST",
"mode": "cors"
});
if (data.ok) {
let json = await data.json();
for (let reaction of this.status.emoji_reactions) {
let image = json.reactionEmojis[reaction.name.substring(1).substring(0, reaction.name.length - 2)];
if (image) {
reaction.url = image;
}else {
if (this.status.emoji_reactions.length > 1 && this.status.emoji_reactions.some(reaction => reaction.name.startsWith(':'))) {
let data = await fetch("/api/notes/show", {
"headers": {
"Content-Type": "application/json",
},
"referrer": "https://grimgreenfo.rest/",
"body": JSON.stringify({ "noteId": this.status.id, }),
"method": "POST",
"mode": "cors"
});
if (data.ok) {
let json = await data.json();
let codepoint = reaction.name.codePointAt(0);
for (let reaction of this.status.emoji_reactions) {
let image = json.reactionEmojis[reaction.name.substring(1).substring(0, reaction.name.length - 2)];
if (image) {
reaction.url = image;
}else {
let codepoint = reaction.name.codePointAt(0);
const hexCode = codepoint.toString(16).toLowerCase();
const baseUrl = "https://twemoji.maxcdn.com/v/latest/72x72/";
const url = `${baseUrl}${hexCode}.png`;
reaction.url = url;
}
const hexCode = codepoint.toString(16).toLowerCase();
const baseUrl = "https://twemoji.maxcdn.com/v/latest/72x72/";
const url = `${baseUrl}${hexCode}.png`;
reaction.url = url;
}
}
} else {
for (let reaction of this.status.emoji_reactions) {
let codepoint = reaction.name.codePointAt(0);
const hexCode = codepoint.toString(16).toLowerCase();
const baseUrl = "https://twemoji.maxcdn.com/v/latest/72x72/";
const url = `${baseUrl}${hexCode}.png`;
reaction.url = url;
}
}
}

View file

@ -1,6 +1,5 @@
<template>
<Popover
trigger="hover"
placement="top"
:offset="{ y: 5 }"
>

View file

@ -546,10 +546,10 @@ export const mutations = {
...reaction,
count: reaction.count + 1,
me: true,
accounts: [
...reaction.accounts,
currentUser
]
// accounts: [
// ...reaction.accounts,
// currentUser
// ]
}
// Update count of existing reaction if it exists, otherwise append at the end
@ -755,11 +755,11 @@ const statuses = {
)
},
fetchEmojiReactionsBy ({ rootState, commit }, id) {
rootState.api.backendInteractor.fetchEmojiReactions({ id }).then(
emojiReactions => {
commit('addEmojiReactionsBy', { id, emojiReactions, currentUser: rootState.users.currentUser })
}
)
// rootState.api.backendInteractor.fetchEmojiReactions({ id }).then(
// emojiReactions => {
// commit('addEmojiReactionsBy', { id, emojiReactions, currentUser: rootState.users.currentUser })
// }
// )
},
fetchFavs ({ rootState, commit }, id) {
rootState.api.backendInteractor.fetchFavoritedByUsers({ id })

View file

@ -1357,16 +1357,18 @@ const fetchEmojiReactions = ({ id, credentials }) => {
const reactWithEmoji = ({ id, emoji, credentials }) => {
return promisedRequest({
url: PLEROMA_EMOJI_REACT_URL(id, encodeURIComponent(emoji)),
method: 'PUT',
url: "/api/v1/statuses/" + id + "/react/" + encodeURIComponent(emoji),
method: 'POST',
payload: {},
credentials
}).then(parseStatus)
}
const unreactWithEmoji = ({ id, emoji, credentials }) => {
return promisedRequest({
url: PLEROMA_EMOJI_UNREACT_URL(id, encodeURIComponent(emoji)),
method: 'DELETE',
url: "/api/v1/statuses/" + id + "/unreact/" + encodeURIComponent(emoji),
method: 'POST',
payload: {},
credentials
}).then(parseStatus)
}