mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-29 21:15:19 +00:00
Be even less brittle.
This commit is contained in:
@@ -111,8 +111,7 @@ export const ReactionsProvider = ({
|
|||||||
|
|
||||||
// This effect will check the state whenever the membership of the session changes.
|
// This effect will check the state whenever the membership of the session changes.
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
// Fetches the first reaction for a given event. We assume no more than
|
// Fetches the first reaction for a given event.
|
||||||
// one reaction on an event here.
|
|
||||||
const getLastReactionEvent = (
|
const getLastReactionEvent = (
|
||||||
eventId: string,
|
eventId: string,
|
||||||
expectedSender: string,
|
expectedSender: string,
|
||||||
@@ -123,7 +122,12 @@ export const ReactionsProvider = ({
|
|||||||
EventType.Reaction,
|
EventType.Reaction,
|
||||||
);
|
);
|
||||||
const allEvents = relations?.getRelations() ?? [];
|
const allEvents = relations?.getRelations() ?? [];
|
||||||
return allEvents.find((u) => u.event.sender === expectedSender);
|
return allEvents.find(
|
||||||
|
(reaction) =>
|
||||||
|
reaction.event.sender === expectedSender &&
|
||||||
|
reaction.getType() === EventType.Reaction &&
|
||||||
|
reaction.getContent()?.["m.relates_to"]?.key === "🖐️",
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Remove any raised hands for users no longer joined to the call.
|
// Remove any raised hands for users no longer joined to the call.
|
||||||
@@ -148,19 +152,16 @@ export const ReactionsProvider = ({
|
|||||||
removeRaisedHand(m.sender);
|
removeRaisedHand(m.sender);
|
||||||
}
|
}
|
||||||
const reaction = getLastReactionEvent(m.eventId, m.sender);
|
const reaction = getLastReactionEvent(m.eventId, m.sender);
|
||||||
const eventId = reaction?.getId();
|
if (reaction) {
|
||||||
if (!eventId) {
|
const eventId = reaction?.getId();
|
||||||
continue;
|
if (!eventId) {
|
||||||
}
|
continue;
|
||||||
if (reaction && reaction.getType() === EventType.Reaction) {
|
|
||||||
const content = reaction.getContent() as ReactionEventContent;
|
|
||||||
if (content?.["m.relates_to"]?.key === "🖐️") {
|
|
||||||
addRaisedHand(m.sender, {
|
|
||||||
membershipEventId: m.eventId,
|
|
||||||
reactionEventId: eventId,
|
|
||||||
time: new Date(reaction.localTimestamp),
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
addRaisedHand(m.sender, {
|
||||||
|
membershipEventId: m.eventId,
|
||||||
|
reactionEventId: eventId,
|
||||||
|
time: new Date(reaction.localTimestamp),
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Ignoring raisedHands here because we don't want to trigger each time the raised
|
// Ignoring raisedHands here because we don't want to trigger each time the raised
|
||||||
|
|||||||
Reference in New Issue
Block a user