feed: fix multiple upvotes (reactions)
ci/woodpecker/push/woodpecker Pipeline was successful Details

Fixes error when upvoting already starred events.

Now the tooltip should display the reactions again.
pull/35/head
OFF0 2 years ago
parent 9b6f78dff1
commit 96087dc041
Signed by: offbyn
GPG Key ID: 94A2F643C51F37FA

@ -77,6 +77,10 @@ function handleTextNote(evt, relay) {
const replyList = [];
const reactionMap = {};
const getReactionList = (id) => {
return reactionMap[id]?.map(({content}) => content) || [];
};
function handleReaction(evt, relay) {
if (!evt.content.length) {
// console.log('reaction with no content', evt)
@ -110,9 +114,9 @@ function handleReaction(evt, relay) {
const reactions = button.querySelector('[data-reactions]');
reactions.textContent = reactionMap[eventId].length;
if (evt.pubkey === pubkey) {
const star = button.querySelector('img[src$="star.svg"]');
star.setAttribute('src', 'assets/star-fill.svg');
star.setAttribute('title', reactionMap[eventId]);
const star = button.querySelector('img[src*="star"]');
star?.setAttribute('src', 'assets/star-fill.svg');
star?.setAttribute('title', getReactionList(eventId).join(' '));
}
}
}
@ -183,7 +187,7 @@ function createTextNote(evt, relay) {
alt: didReact ? '✭' : '✩', // ♥
height: 24, width: 24,
src: `assets/${didReact ? 'star-fill' : 'star'}.svg`,
title: reactionMap[evt.id]?.map(({content}) => content).join(' '),
title: getReactionList(evt.id).join(' '),
}),
elem('small', {data: {reactions: evt.id}}, hasReactions ? reactionMap[evt.id].length : ''),
]),

Loading…
Cancel
Save