Merge pull request #495 from robintown/fix-crash

Fix a crash
This commit is contained in:
Robin 2022-08-02 13:34:32 -04:00 committed by GitHub
commit c3c2f409e7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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?: Record<string, unknown>;
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 as string;
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 as string,
content: event.getContent(), content: event.content as CallEventContent,
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: Record<string, unknown>) {
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);