From 4a712dcaa24345ec4c9a7d654f785bf288e99bbe Mon Sep 17 00:00:00 2001 From: Half-Shot Date: Mon, 28 Oct 2024 16:11:28 +0000 Subject: [PATCH] Redact the right thing. --- src/useReactions.tsx | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/useReactions.tsx b/src/useReactions.tsx index 72969a7b..8a46ade9 100644 --- a/src/useReactions.tsx +++ b/src/useReactions.tsx @@ -97,16 +97,20 @@ export const ReactionsProvider = ({ const fetchReactions = (): void => { for (const m of memberships) { - if (!m.sender) { + if (!m.sender || !m.eventId) { + continue; + } + const reaction = getLastReactionEvent(m.eventId); + const eventId = reaction?.getId(); + if (!eventId) { continue; } - const reaction = getLastReactionEvent(m.eventId!); if (reaction && reaction.getType() === EventType.Reaction) { const content = reaction.getContent() as ReactionEventContent; - if (content?.["m.relates_to"].key === "🖐️") { + if (content?.["m.relates_to"]?.key === "🖐️") { addRaisedHand(m.sender, new Date(m.createdTs())); if (m.sender === room.client.getUserId()) { - setMyReactionId(m.eventId!); + setMyReactionId(eventId); } } }