This commit is contained in:
Half-Shot
2024-10-31 16:25:31 +00:00
parent ec9dec89bb
commit 21380c7791
3 changed files with 57 additions and 46 deletions
+5 -1
View File
@@ -68,7 +68,8 @@ export function RaiseHandToggleButton({
const isHandRaised = !!raisedHands[userId]; const isHandRaised = !!raisedHands[userId];
const memberships = useMatrixRTCSessionMemberships(rtcSession); const memberships = useMatrixRTCSessionMemberships(rtcSession);
const toggleRaisedHand = useCallback(async () => { const toggleRaisedHand = useCallback(() => {
const raiseHand = async (): Promise<void> => {
if (isHandRaised) { if (isHandRaised) {
if (!myReactionId) { if (!myReactionId) {
logger.warn(`Hand raised but no reaction event to redact!`); logger.warn(`Hand raised but no reaction event to redact!`);
@@ -110,6 +111,9 @@ export function RaiseHandToggleButton({
setBusy(false); setBusy(false);
} }
} }
};
void raiseHand();
}, [ }, [
client, client,
isHandRaised, isHandRaised,
+4 -4
View File
@@ -214,17 +214,17 @@ describe("useReactions", () => {
}); });
// If the membership event changes for a user, we want to remove // If the membership event changes for a user, we want to remove
// the raised hand event. // the raised hand event.
test("will remove reaction when a member leaves the call", async () => { test("will remove reaction when a member leaves the call", () => {
const room = new MockRoom([createReaction(memberEventAlice)]); const room = new MockRoom([createReaction(memberEventAlice)]);
const rtcSession = new MockRTCSession(room); const rtcSession = new MockRTCSession(room);
const { queryByRole } = render( const { queryByRole } = render(
<TestComponentWrapper rtcSession={rtcSession} />, <TestComponentWrapper rtcSession={rtcSession} />,
); );
expect(queryByRole("list")?.children).to.have.lengthOf(1); expect(queryByRole("list")?.children).to.have.lengthOf(1);
await act(() => rtcSession.testRemoveMember(memberUserIdAlice)); act(() => rtcSession.testRemoveMember(memberUserIdAlice));
expect(queryByRole("list")?.children).to.have.lengthOf(0); expect(queryByRole("list")?.children).to.have.lengthOf(0);
}); });
test("will remove reaction when a member joins via a new event", async () => { test("will remove reaction when a member joins via a new event", () => {
const room = new MockRoom([createReaction(memberEventAlice)]); const room = new MockRoom([createReaction(memberEventAlice)]);
const rtcSession = new MockRTCSession(room); const rtcSession = new MockRTCSession(room);
const { queryByRole } = render( const { queryByRole } = render(
@@ -232,7 +232,7 @@ describe("useReactions", () => {
); );
expect(queryByRole("list")?.children).to.have.lengthOf(1); expect(queryByRole("list")?.children).to.have.lengthOf(1);
// Simulate leaving and rejoining // Simulate leaving and rejoining
await act(() => { act(() => {
rtcSession.testRemoveMember(memberUserIdAlice); rtcSession.testRemoveMember(memberUserIdAlice);
rtcSession.testAddMember(memberUserIdAlice); rtcSession.testAddMember(memberUserIdAlice);
}); });
+9 -2
View File
@@ -84,7 +84,7 @@ export const ReactionsProvider = ({
const myReactionId = useMemo( const myReactionId = useMemo(
(): string | null => (): string | null =>
(myUserId && raisedHands[myUserId]?.reactionEventId) ?? null, (myUserId && raisedHands[myUserId]?.reactionEventId) ?? null,
[raisedHands, room], [raisedHands, myUserId],
); );
// Reduce the data down for the consumers. // Reduce the data down for the consumers.
@@ -160,7 +160,14 @@ export const ReactionsProvider = ({
} }
} }
} }
}, [room, memberships, addRaisedHand, removeRaisedHand]); }, [
room,
memberships,
myUserId,
raisedHands,
addRaisedHand,
removeRaisedHand,
]);
// This effect handles any *live* reaction/redactions in the room. // This effect handles any *live* reaction/redactions in the room.
useEffect(() => { useEffect(() => {