diff --git a/src/state/CallViewModel.test.ts b/src/state/CallViewModel.test.ts index 986abf4a..910075e6 100644 --- a/src/state/CallViewModel.test.ts +++ b/src/state/CallViewModel.test.ts @@ -31,7 +31,7 @@ import { mockLivekitRoom, mockLocalParticipant, mockMatrixRoom, - mockRoomMember, + mockMatrixRoomMember, mockRemoteParticipant, withTestScheduler, mockRtcMembership, @@ -50,10 +50,10 @@ const aliceRtcMember = mockRtcMembership("@alice:example.org", "AAAA"); const bobRtcMember = mockRtcMembership("@bob:example.org", "BBBB"); const daveRtcMember = mockRtcMembership("@dave:example.org", "DDDD"); -const alice = mockRoomMember(aliceRtcMember); -const bob = mockRoomMember(bobRtcMember); -const carol = mockRoomMember(localRtcMember); -const dave = mockRoomMember(daveRtcMember); +const alice = mockMatrixRoomMember(aliceRtcMember); +const bob = mockMatrixRoomMember(bobRtcMember); +const carol = mockMatrixRoomMember(localRtcMember); +const dave = mockMatrixRoomMember(daveRtcMember); const aliceId = `${alice.userId}:${aliceRtcMember.deviceId}`; const bobId = `${bob.userId}:${bobRtcMember.deviceId}`; diff --git a/src/state/CallViewModel.ts b/src/state/CallViewModel.ts index cd00e252..aaf7a585 100644 --- a/src/state/CallViewModel.ts +++ b/src/state/CallViewModel.ts @@ -375,12 +375,16 @@ export class CallViewModel extends ViewModel { }), ); - private readonly rawRemoteParticipants = connectedParticipantsObserver( - this.livekitRoom, - ).pipe(this.scope.state()); + /** + * The raw list of RemoteParticipants as reported by LiveKit + */ + private readonly rawRemoteParticipants: Observable = + connectedParticipantsObserver(this.livekitRoom).pipe(this.scope.state()); - // Lists of RemoteParticipants to "hold" on display, even if LiveKit claims that - // they've left + /** + * Lists of RemoteParticipants to "hold" on display, even if LiveKit claims that + * they've left + */ private readonly remoteParticipantHolds: Observable = this.connectionState.pipe( withLatestFrom(this.rawRemoteParticipants), @@ -415,6 +419,9 @@ export class CallViewModel extends ViewModel { ), ); + /** + * The RemoteParticipants including those that are being "held" on the screen + */ private readonly remoteParticipants: Observable = combineLatest( [this.rawRemoteParticipants, this.remoteParticipantHolds], @@ -436,6 +443,9 @@ export class CallViewModel extends ViewModel { }, ); + /** + * List of MediaItems that we want to display + */ private readonly mediaItems: Observable = combineLatest([ this.remoteParticipants, observeParticipantMedia(this.livekitRoom.localParticipant), @@ -541,12 +551,18 @@ export class CallViewModel extends ViewModel { this.scope.state(), ); + /** + * List of MediaItems that we want to display, that are of type UserMedia + */ private readonly userMedia: Observable = this.mediaItems.pipe( map((mediaItems) => mediaItems.filter((m): m is UserMedia => m instanceof UserMedia), ), ); + /** + * List of MediaItems that we want to display, that are of type ScreenShare + */ private readonly screenShares: Observable = this.mediaItems.pipe( map((mediaItems) => @@ -1021,7 +1037,7 @@ export class CallViewModel extends ViewModel { this.scope.state(), ); - public readonly showFooter = this.windowMode.pipe( + public readonly showFooter: Observable = this.windowMode.pipe( switchMap((mode) => { switch (mode) { case "pip": diff --git a/src/utils/test.ts b/src/utils/test.ts index cf1d9ec1..53d2a525 100644 --- a/src/utils/test.ts +++ b/src/utils/test.ts @@ -134,7 +134,7 @@ export function mockRtcMembership( // Maybe it'd be good to move this to matrix-js-sdk? Our testing needs are // rather simple, but if one util to mock a member is good enough for us, maybe // it's useful for matrix-js-sdk consumers in general. -export function mockRoomMember( +export function mockMatrixRoomMember( rtcMembership: CallMembership, member: Partial = {}, ): RoomMember { @@ -192,7 +192,7 @@ export async function withLocalMedia( const localParticipant = mockLocalParticipant({}); const vm = new LocalUserMediaViewModel( "local", - mockRoomMember(localRtcMember, roomMember), + mockMatrixRoomMember(localRtcMember, roomMember), of(localParticipant), { kind: E2eeType.PER_PARTICIPANT, @@ -228,7 +228,7 @@ export async function withRemoteMedia( const remoteParticipant = mockRemoteParticipant(participant); const vm = new RemoteUserMediaViewModel( "remote", - mockRoomMember(localRtcMember, roomMember), + mockMatrixRoomMember(localRtcMember, roomMember), of(remoteParticipant), { kind: E2eeType.PER_PARTICIPANT,