Skip to content

Commit 2a5dc60

Browse files
committed
merge fixes
1 parent e1e202d commit 2a5dc60

File tree

1 file changed

+16
-6
lines changed

1 file changed

+16
-6
lines changed

src/state/CallViewModel.ts

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ import { duplicateTiles, nonMemberTiles } from "../settings/settings";
7272
import { isFirefox } from "../Platform";
7373
import { setPipEnabled } from "../controls";
7474
import { EncryptionSystem } from "../e2ee/sharedKeyManagement";
75-
import { Config } from "../config/Config";
7675

7776
// How long we wait after a focus switch before showing the real participant
7877
// list again
@@ -295,11 +294,11 @@ function findMatrixRoomMember(
295294
export class CallViewModel extends ViewModel {
296295
public readonly localVideo: Observable<LocalVideoTrack | null> =
297296
observeTrackReference(
298-
this.livekitRoom.localParticipant,
297+
of(this.livekitRoom.localParticipant),
299298
Track.Source.Camera,
300299
).pipe(
301300
map((trackRef) => {
302-
const track = trackRef.publication?.track;
301+
const track = trackRef?.publication?.track;
303302
return track instanceof LocalVideoTrack ? track : null;
304303
}),
305304
);
@@ -366,6 +365,7 @@ export class CallViewModel extends ViewModel {
366365
);
367366

368367
public readonly nonMemberItemCount = new BehaviorSubject<number>(0);
368+
369369
private readonly mediaItems: Observable<MediaItem[]> = combineLatest([
370370
this.remoteParticipants,
371371
observeParticipantMedia(this.livekitRoom.localParticipant),
@@ -409,15 +409,25 @@ export class CallViewModel extends ViewModel {
409409
}
410410

411411
const member = findMatrixRoomMember(room, mediaId);
412-
412+
if (!member) {
413+
logger.error("Could not find member for media id: ", mediaId);
414+
}
413415
for (let i = 0; i < 1 + duplicateTiles; i++) {
414416
const indexedMediaId = `${mediaId}:${i}`;
415-
const prevMedia = prevItems.get(indexedMediaId);
417+
let prevMedia = prevItems.get(indexedMediaId);
416418
if (prevMedia && prevMedia instanceof UserMedia) {
417419
if (prevMedia.participant.value !== participant) {
418420
// Update the BahviourSubject in the UserMedia.
419421
prevMedia.participant.next(participant);
420422
}
423+
if (prevMedia.vm.member === undefined) {
424+
// We have a previous media created because of the `debugShowNonMember` flag.
425+
// In this case we actually replace the media item.
426+
// This "hack" never occurs if we do not use the `debugShowNonMember` debugging
427+
// option and if we always find a room member for each rtc member (which also
428+
// only fails if we have a fundamental problem)
429+
prevMedia = undefined;
430+
}
421431
}
422432
yield [
423433
indexedMediaId,
@@ -483,7 +493,7 @@ export class CallViewModel extends ViewModel {
483493
nonMemberId,
484494
undefined,
485495
participant,
486-
this.encrypted,
496+
this.encryptionSystem,
487497
this.matrixRTCSession,
488498
),
489499
];

0 commit comments

Comments
 (0)