mirror of
https://github.com/vector-im/element-call.git
synced 2026-08-29 21:15:19 +00:00
Add some explanation comments.
This commit is contained in:
@@ -72,6 +72,7 @@ export const ReactionsProvider = ({
|
||||
clientState?.state === "valid" && clientState.supportedFeatures.reactions;
|
||||
const room = rtcSession.room;
|
||||
|
||||
// Calculate our own reaction event.
|
||||
const myReactionId = useMemo((): string | null => {
|
||||
const myUserId = room.client.getUserId();
|
||||
if (myUserId) {
|
||||
@@ -80,6 +81,15 @@ export const ReactionsProvider = ({
|
||||
return null;
|
||||
}, [raisedHands, room]);
|
||||
|
||||
// Reduce the data down for the consumers.
|
||||
const resultRaisedHands = useMemo(
|
||||
() =>
|
||||
Object.fromEntries(
|
||||
Object.entries(raisedHands).map(([uid, data]) => [uid, data.time]),
|
||||
),
|
||||
[raisedHands],
|
||||
);
|
||||
|
||||
const addRaisedHand = useCallback(
|
||||
(userId: string, info: RaisedHandInfo) => {
|
||||
setRaisedHands({
|
||||
@@ -98,7 +108,7 @@ export const ReactionsProvider = ({
|
||||
[raisedHands],
|
||||
);
|
||||
|
||||
// Load any existing reactions.
|
||||
// This effect will check the state whenever the membership of the session changes.
|
||||
useEffect(() => {
|
||||
const getLastReactionEvent = (eventId: string): MatrixEvent | undefined => {
|
||||
const relations = room.relations.getChildEventsForEvent(
|
||||
@@ -148,6 +158,7 @@ export const ReactionsProvider = ({
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [room, memberships]);
|
||||
|
||||
// This effect handles any *live* reaction/redactions in the room.
|
||||
useEffect(() => {
|
||||
const handleReactionEvent = (event: MatrixEvent): void => {
|
||||
const sender = event.getSender();
|
||||
@@ -201,15 +212,6 @@ export const ReactionsProvider = ({
|
||||
};
|
||||
}, [room, addRaisedHand, removeRaisedHand, memberships, raisedHands]);
|
||||
|
||||
// Reduce the data down for the consumers.
|
||||
const resultRaisedHands = useMemo(
|
||||
() =>
|
||||
Object.fromEntries(
|
||||
Object.entries(raisedHands).map(([uid, data]) => [uid, data.time]),
|
||||
),
|
||||
[raisedHands],
|
||||
);
|
||||
|
||||
return (
|
||||
<ReactionsContext.Provider
|
||||
value={{
|
||||
|
||||
Reference in New Issue
Block a user