mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-29 21:15:19 +00:00
Tidy up useEffect
This commit is contained in:
@@ -95,30 +95,28 @@ export const ReactionsProvider = ({
|
|||||||
return allEvents.length > 0 ? allEvents[0] : undefined;
|
return allEvents.length > 0 ? allEvents[0] : undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchReactions = (): void => {
|
for (const m of memberships) {
|
||||||
for (const m of memberships) {
|
if (!m.sender || !m.eventId) {
|
||||||
if (!m.sender || !m.eventId) {
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
const reaction = getLastReactionEvent(m.eventId);
|
||||||
const reaction = getLastReactionEvent(m.eventId);
|
const eventId = reaction?.getId();
|
||||||
const eventId = reaction?.getId();
|
if (!eventId) {
|
||||||
if (!eventId) {
|
continue;
|
||||||
continue;
|
}
|
||||||
}
|
if (reaction && reaction.getType() === EventType.Reaction) {
|
||||||
if (reaction && reaction.getType() === EventType.Reaction) {
|
const content = reaction.getContent() as ReactionEventContent;
|
||||||
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()));
|
||||||
addRaisedHand(m.sender, new Date(m.createdTs()));
|
if (m.sender === room.client.getUserId()) {
|
||||||
if (m.sender === room.client.getUserId()) {
|
setMyReactionId(eventId);
|
||||||
setMyReactionId(eventId);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
// Deliberately ignoring addRaisedHand which was causing looping.
|
||||||
void fetchReactions();
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, [room, addRaisedHand, memberships]);
|
}, [room, memberships]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const handleReactionEvent = (event: MatrixEvent): void => {
|
const handleReactionEvent = (event: MatrixEvent): void => {
|
||||||
|
|||||||
Reference in New Issue
Block a user