Fix a crash

CallEvent.SendVoipEvent is sent with a raw dictionary, not an actual
MatrixEvent.
This commit is contained in:
Robin Townsend 2022-08-02 13:21:34 -04:00
parent 3de8f9077d
commit 9b915d289b

View file

@ -230,7 +230,8 @@ function reducer(
state: InspectorContextState, state: InspectorContextState,
action: { action: {
type?: CallEvent | ClientEvent | RoomStateEvent; type?: CallEvent | ClientEvent | RoomStateEvent;
event: MatrixEvent; event?: MatrixEvent;
rawEvent?: object;
callStateEvent?: MatrixEvent; callStateEvent?: MatrixEvent;
memberStateEvents?: MatrixEvent[]; memberStateEvents?: MatrixEvent[];
} }
@ -317,10 +318,10 @@ function reducer(
return { ...state, eventsByUserId, remoteUserIds }; return { ...state, eventsByUserId, remoteUserIds };
} }
case CallEvent.SendVoipEvent: { case CallEvent.SendVoipEvent: {
const event = action.event; const event = action.rawEvent;
const eventsByUserId = { ...state.eventsByUserId }; const eventsByUserId = { ...state.eventsByUserId };
const fromId = state.localUserId; const fromId = state.localUserId;
const toId = event.target.userId; // was .user const toId = event.userId;
const remoteUserIds = eventsByUserId[toId] const remoteUserIds = eventsByUserId[toId]
? state.remoteUserIds ? state.remoteUserIds
@ -331,8 +332,8 @@ function reducer(
{ {
from: fromId, from: fromId,
to: toId, to: toId,
type: event.getType(), type: event.eventType,
content: event.getContent(), content: event.content,
timestamp: Date.now(), timestamp: Date.now(),
ignored: false, ignored: false,
}, },
@ -382,8 +383,8 @@ function useGroupCallState(
dispatch({ type: ClientEvent.ReceivedVoipEvent, event }); dispatch({ type: ClientEvent.ReceivedVoipEvent, event });
} }
function onSendVoipEvent(event: MatrixEvent) { function onSendVoipEvent(event: object) {
dispatch({ type: CallEvent.SendVoipEvent, event }); dispatch({ type: CallEvent.SendVoipEvent, rawEvent: event });
} }
client.on(RoomStateEvent.Events, onUpdateRoomState); client.on(RoomStateEvent.Events, onUpdateRoomState);
//groupCall.on("calls_changed", onCallsChanged); //groupCall.on("calls_changed", onCallsChanged);