fix reactions but actually this time
This commit is contained in:
parent
8a17e3f95e
commit
54b440b9f5
5 changed files with 49 additions and 37 deletions
|
@ -9,7 +9,6 @@
|
||||||
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 }"
|
||||||
@click="emojiOnClick(reaction.name, $event)"
|
@click="emojiOnClick(reaction.name, $event)"
|
||||||
@mouseenter="fetchEmojiReactionsByIfMissing()"
|
|
||||||
>
|
>
|
||||||
<span
|
<span
|
||||||
v-if="reaction.url !== null"
|
v-if="reaction.url !== null"
|
||||||
|
|
|
@ -564,33 +564,45 @@ const Status = {
|
||||||
},
|
},
|
||||||
async mounted () {
|
async mounted () {
|
||||||
if (this.status.refetched) return;
|
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) {
|
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 image = json.reactionEmojis[reaction.name.substring(1).substring(0, reaction.name.length - 2)];
|
for (let reaction of this.status.emoji_reactions) {
|
||||||
if (image) {
|
|
||||||
reaction.url = image;
|
|
||||||
}else {
|
|
||||||
|
|
||||||
let codepoint = reaction.name.codePointAt(0);
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,5 @@
|
||||||
<template>
|
<template>
|
||||||
<Popover
|
<Popover
|
||||||
trigger="hover"
|
|
||||||
placement="top"
|
placement="top"
|
||||||
:offset="{ y: 5 }"
|
:offset="{ y: 5 }"
|
||||||
>
|
>
|
||||||
|
|
|
@ -546,10 +546,10 @@ export const mutations = {
|
||||||
...reaction,
|
...reaction,
|
||||||
count: reaction.count + 1,
|
count: reaction.count + 1,
|
||||||
me: true,
|
me: true,
|
||||||
accounts: [
|
// accounts: [
|
||||||
...reaction.accounts,
|
// ...reaction.accounts,
|
||||||
currentUser
|
// currentUser
|
||||||
]
|
// ]
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update count of existing reaction if it exists, otherwise append at the end
|
// Update count of existing reaction if it exists, otherwise append at the end
|
||||||
|
@ -755,11 +755,11 @@ const statuses = {
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
fetchEmojiReactionsBy ({ rootState, commit }, id) {
|
fetchEmojiReactionsBy ({ rootState, commit }, id) {
|
||||||
rootState.api.backendInteractor.fetchEmojiReactions({ id }).then(
|
// rootState.api.backendInteractor.fetchEmojiReactions({ id }).then(
|
||||||
emojiReactions => {
|
// emojiReactions => {
|
||||||
commit('addEmojiReactionsBy', { id, emojiReactions, currentUser: rootState.users.currentUser })
|
// commit('addEmojiReactionsBy', { id, emojiReactions, currentUser: rootState.users.currentUser })
|
||||||
}
|
// }
|
||||||
)
|
// )
|
||||||
},
|
},
|
||||||
fetchFavs ({ rootState, commit }, id) {
|
fetchFavs ({ rootState, commit }, id) {
|
||||||
rootState.api.backendInteractor.fetchFavoritedByUsers({ id })
|
rootState.api.backendInteractor.fetchFavoritedByUsers({ id })
|
||||||
|
|
|
@ -1357,16 +1357,18 @@ const fetchEmojiReactions = ({ id, credentials }) => {
|
||||||
|
|
||||||
const reactWithEmoji = ({ id, emoji, credentials }) => {
|
const reactWithEmoji = ({ id, emoji, credentials }) => {
|
||||||
return promisedRequest({
|
return promisedRequest({
|
||||||
url: PLEROMA_EMOJI_REACT_URL(id, encodeURIComponent(emoji)),
|
url: "/api/v1/statuses/" + id + "/react/" + encodeURIComponent(emoji),
|
||||||
method: 'PUT',
|
method: 'POST',
|
||||||
|
payload: {},
|
||||||
credentials
|
credentials
|
||||||
}).then(parseStatus)
|
}).then(parseStatus)
|
||||||
}
|
}
|
||||||
|
|
||||||
const unreactWithEmoji = ({ id, emoji, credentials }) => {
|
const unreactWithEmoji = ({ id, emoji, credentials }) => {
|
||||||
return promisedRequest({
|
return promisedRequest({
|
||||||
url: PLEROMA_EMOJI_UNREACT_URL(id, encodeURIComponent(emoji)),
|
url: "/api/v1/statuses/" + id + "/unreact/" + encodeURIComponent(emoji),
|
||||||
method: 'DELETE',
|
method: 'POST',
|
||||||
|
payload: {},
|
||||||
credentials
|
credentials
|
||||||
}).then(parseStatus)
|
}).then(parseStatus)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue