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 }"
>