From 1b5b9342fe80005bb64dc01af6defd769da0892f Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 11 Sep 2024 01:27:02 -0400 Subject: [PATCH 1/2] Warn about duplicate rooms --- src/room/GroupCallView.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/room/GroupCallView.tsx b/src/room/GroupCallView.tsx index f1986d4b..af97ce07 100644 --- a/src/room/GroupCallView.tsx +++ b/src/room/GroupCallView.tsx @@ -85,6 +85,14 @@ export const GroupCallView: FC = ({ }; }, [rtcSession]); + useEffect(() => { + // Sanity check the room object + if (client.getRoom(rtcSession.room.roomId) !== rtcSession.room) + logger.warn( + `We've ended up with multiple rooms for the same ID (${rtcSession.room.roomId}). This indicates a bug in the group call loading code, and may lead to incomplete room state.`, + ); + }, [client, rtcSession.room]); + const { displayName, avatarUrl } = useProfile(client); const roomName = useRoomName(rtcSession.room); const roomAvatar = useRoomAvatar(rtcSession.room); From ca135d471e97d5af96b0dd9d46aec2c178d1975c Mon Sep 17 00:00:00 2001 From: Robin Date: Wed, 11 Sep 2024 01:27:24 -0400 Subject: [PATCH 2/2] React more actively to changes in room membership --- src/state/CallViewModel.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/state/CallViewModel.ts b/src/state/CallViewModel.ts index 219df600..6cd8495b 100644 --- a/src/state/CallViewModel.ts +++ b/src/state/CallViewModel.ts @@ -16,7 +16,11 @@ import { ParticipantEvent, RemoteParticipant, } from "livekit-client"; -import { Room as MatrixRoom, RoomMember } from "matrix-js-sdk/src/matrix"; +import { + Room as MatrixRoom, + RoomMember, + RoomStateEvent, +} from "matrix-js-sdk/src/matrix"; import { EMPTY, Observable, @@ -321,6 +325,8 @@ export class CallViewModel extends ViewModel { this.remoteParticipants, observeParticipantMedia(this.livekitRoom.localParticipant), duplicateTiles.value, + // Also react to changes in the list of members + fromEvent(this.matrixRoom, RoomStateEvent.Update).pipe(startWith(null)), ]).pipe( scan( (