mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-02 19:49:23 +00:00
Links to sha commit of matrix-js-sdk that exposes the call membership event id and refactors some async code
Signed-off-by: Milton Moura <miltonmoura@gmail.com>
This commit is contained in:
@@ -320,17 +320,19 @@ export const InCallView: FC<InCallViewProps> = ({
|
|||||||
const getLastReactionEvent = async (
|
const getLastReactionEvent = async (
|
||||||
eventId: string,
|
eventId: string,
|
||||||
): Promise<MatrixEvent | undefined> => {
|
): Promise<MatrixEvent | undefined> => {
|
||||||
const rels = await client.relations(
|
return client
|
||||||
rtcSession.room.roomId,
|
.relations(
|
||||||
eventId,
|
rtcSession.room.roomId,
|
||||||
RelationType.Annotation,
|
eventId,
|
||||||
EventType.Reaction,
|
RelationType.Annotation,
|
||||||
{
|
EventType.Reaction,
|
||||||
limit: 1,
|
{
|
||||||
},
|
limit: 1,
|
||||||
);
|
},
|
||||||
|
)
|
||||||
return rels.events.length > 0 ? rels.events[0] : undefined;
|
.then((rels) => {
|
||||||
|
return rels.events.length > 0 ? rels.events[0] : undefined;
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
const fetchReactions = async (): Promise<void> => {
|
const fetchReactions = async (): Promise<void> => {
|
||||||
@@ -347,7 +349,7 @@ export const InCallView: FC<InCallViewProps> = ({
|
|||||||
setRaisedHands(newRaisedHands);
|
setRaisedHands(newRaisedHands);
|
||||||
};
|
};
|
||||||
|
|
||||||
fetchReactions();
|
void fetchReactions();
|
||||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||||
}, []);
|
}, []);
|
||||||
|
|
||||||
@@ -556,43 +558,39 @@ export const InCallView: FC<InCallViewProps> = ({
|
|||||||
.catch(logger.error);
|
.catch(logger.error);
|
||||||
}, [localParticipant, isScreenShareEnabled]);
|
}, [localParticipant, isScreenShareEnabled]);
|
||||||
|
|
||||||
const toggleRaisedHand = useCallback(async () => {
|
const toggleRaisedHand = useCallback(() => {
|
||||||
try {
|
if (isHandRaised) {
|
||||||
if (isHandRaised) {
|
if (reactionId) {
|
||||||
try {
|
client
|
||||||
if (reactionId) {
|
.redactEvent(rtcSession.room.roomId, reactionId)
|
||||||
await client.redactEvent(rtcSession.room.roomId, reactionId);
|
.then(() => {
|
||||||
setReactionId(null);
|
setReactionId(null);
|
||||||
setRaisedHands(raisedHands.filter((id) => id !== userId));
|
setRaisedHands(raisedHands.filter((id) => id !== userId));
|
||||||
logger.debug("Redacted reaction event");
|
logger.debug("Redacted reaction event");
|
||||||
}
|
})
|
||||||
} catch (e) {
|
.catch((e) => {
|
||||||
logger.error("Failed to redact reaction event", e);
|
logger.error("Failed to redact reaction event", e);
|
||||||
}
|
});
|
||||||
} else {
|
}
|
||||||
const m = memberships.filter((m) => m.sender === userId);
|
} else {
|
||||||
const eventId = m[0].eventId!;
|
const m = memberships.filter((m) => m.sender === userId);
|
||||||
try {
|
const eventId = m[0].eventId!;
|
||||||
const reaction = await client.sendEvent(
|
client
|
||||||
rtcSession.room.roomId,
|
.sendEvent(rtcSession.room.roomId, EventType.Reaction, {
|
||||||
EventType.Reaction,
|
"m.relates_to": {
|
||||||
{
|
rel_type: RelationType.Annotation,
|
||||||
"m.relates_to": {
|
event_id: eventId,
|
||||||
rel_type: RelationType.Annotation,
|
key: "🖐️",
|
||||||
event_id: eventId,
|
},
|
||||||
key: "🖐️",
|
})
|
||||||
},
|
.then((reaction) => {
|
||||||
},
|
|
||||||
);
|
|
||||||
setReactionId(reaction.event_id);
|
setReactionId(reaction.event_id);
|
||||||
setRaisedHands([...raisedHands, userId]);
|
setRaisedHands([...raisedHands, userId]);
|
||||||
logger.debug("Sent reaction event", reaction.event_id);
|
logger.debug("Sent reaction event", reaction.event_id);
|
||||||
} catch (e) {
|
})
|
||||||
|
.catch((e) => {
|
||||||
logger.error("Failed to send reaction event", e);
|
logger.error("Failed to send reaction event", e);
|
||||||
}
|
});
|
||||||
}
|
|
||||||
} catch (e) {
|
|
||||||
logger.error(e);
|
|
||||||
}
|
}
|
||||||
}, [
|
}, [
|
||||||
client,
|
client,
|
||||||
|
|||||||
Reference in New Issue
Block a user