From 9b915d289b5af6bf67a654b38b63ad997e0916c5 Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Tue, 2 Aug 2022 13:21:34 -0400 Subject: [PATCH 1/2] Fix a crash CallEvent.SendVoipEvent is sent with a raw dictionary, not an actual MatrixEvent. --- src/room/GroupCallInspector.tsx | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/room/GroupCallInspector.tsx b/src/room/GroupCallInspector.tsx index 813168eb..5d09ea0a 100644 --- a/src/room/GroupCallInspector.tsx +++ b/src/room/GroupCallInspector.tsx @@ -230,7 +230,8 @@ function reducer( state: InspectorContextState, action: { type?: CallEvent | ClientEvent | RoomStateEvent; - event: MatrixEvent; + event?: MatrixEvent; + rawEvent?: object; callStateEvent?: MatrixEvent; memberStateEvents?: MatrixEvent[]; } @@ -317,10 +318,10 @@ function reducer( return { ...state, eventsByUserId, remoteUserIds }; } case CallEvent.SendVoipEvent: { - const event = action.event; + const event = action.rawEvent; const eventsByUserId = { ...state.eventsByUserId }; const fromId = state.localUserId; - const toId = event.target.userId; // was .user + const toId = event.userId; const remoteUserIds = eventsByUserId[toId] ? state.remoteUserIds @@ -331,8 +332,8 @@ function reducer( { from: fromId, to: toId, - type: event.getType(), - content: event.getContent(), + type: event.eventType, + content: event.content, timestamp: Date.now(), ignored: false, }, @@ -382,8 +383,8 @@ function useGroupCallState( dispatch({ type: ClientEvent.ReceivedVoipEvent, event }); } - function onSendVoipEvent(event: MatrixEvent) { - dispatch({ type: CallEvent.SendVoipEvent, event }); + function onSendVoipEvent(event: object) { + dispatch({ type: CallEvent.SendVoipEvent, rawEvent: event }); } client.on(RoomStateEvent.Events, onUpdateRoomState); //groupCall.on("calls_changed", onCallsChanged); From 89312ceb5868eb372414e97009e4e6ee09ad879a Mon Sep 17 00:00:00 2001 From: Robin Townsend Date: Tue, 2 Aug 2022 13:31:11 -0400 Subject: [PATCH 2/2] Fix types --- src/room/GroupCallInspector.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/room/GroupCallInspector.tsx b/src/room/GroupCallInspector.tsx index 5d09ea0a..4afd1718 100644 --- a/src/room/GroupCallInspector.tsx +++ b/src/room/GroupCallInspector.tsx @@ -231,7 +231,7 @@ function reducer( action: { type?: CallEvent | ClientEvent | RoomStateEvent; event?: MatrixEvent; - rawEvent?: object; + rawEvent?: Record; callStateEvent?: MatrixEvent; memberStateEvents?: MatrixEvent[]; } @@ -321,7 +321,7 @@ function reducer( const event = action.rawEvent; const eventsByUserId = { ...state.eventsByUserId }; const fromId = state.localUserId; - const toId = event.userId; + const toId = event.userId as string; const remoteUserIds = eventsByUserId[toId] ? state.remoteUserIds @@ -332,8 +332,8 @@ function reducer( { from: fromId, to: toId, - type: event.eventType, - content: event.content, + type: event.eventType as string, + content: event.content as CallEventContent, timestamp: Date.now(), ignored: false, }, @@ -383,7 +383,7 @@ function useGroupCallState( dispatch({ type: ClientEvent.ReceivedVoipEvent, event }); } - function onSendVoipEvent(event: object) { + function onSendVoipEvent(event: Record) { dispatch({ type: CallEvent.SendVoipEvent, rawEvent: event }); } client.on(RoomStateEvent.Events, onUpdateRoomState);