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,
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);