@@ -72,7 +72,6 @@ import { duplicateTiles, nonMemberTiles } from "../settings/settings";
72
72
import { isFirefox } from "../Platform" ;
73
73
import { setPipEnabled } from "../controls" ;
74
74
import { EncryptionSystem } from "../e2ee/sharedKeyManagement" ;
75
- import { Config } from "../config/Config" ;
76
75
77
76
// How long we wait after a focus switch before showing the real participant
78
77
// list again
@@ -295,11 +294,11 @@ function findMatrixRoomMember(
295
294
export class CallViewModel extends ViewModel {
296
295
public readonly localVideo : Observable < LocalVideoTrack | null > =
297
296
observeTrackReference (
298
- this . livekitRoom . localParticipant ,
297
+ of ( this . livekitRoom . localParticipant ) ,
299
298
Track . Source . Camera ,
300
299
) . pipe (
301
300
map ( ( trackRef ) => {
302
- const track = trackRef . publication ?. track ;
301
+ const track = trackRef ? .publication ?. track ;
303
302
return track instanceof LocalVideoTrack ? track : null ;
304
303
} ) ,
305
304
) ;
@@ -366,6 +365,7 @@ export class CallViewModel extends ViewModel {
366
365
) ;
367
366
368
367
public readonly nonMemberItemCount = new BehaviorSubject < number > ( 0 ) ;
368
+
369
369
private readonly mediaItems : Observable < MediaItem [ ] > = combineLatest ( [
370
370
this . remoteParticipants ,
371
371
observeParticipantMedia ( this . livekitRoom . localParticipant ) ,
@@ -409,15 +409,25 @@ export class CallViewModel extends ViewModel {
409
409
}
410
410
411
411
const member = findMatrixRoomMember ( room , mediaId ) ;
412
-
412
+ if ( ! member ) {
413
+ logger . error ( "Could not find member for media id: " , mediaId ) ;
414
+ }
413
415
for ( let i = 0 ; i < 1 + duplicateTiles ; i ++ ) {
414
416
const indexedMediaId = `${ mediaId } :${ i } ` ;
415
- const prevMedia = prevItems . get ( indexedMediaId ) ;
417
+ let prevMedia = prevItems . get ( indexedMediaId ) ;
416
418
if ( prevMedia && prevMedia instanceof UserMedia ) {
417
419
if ( prevMedia . participant . value !== participant ) {
418
420
// Update the BahviourSubject in the UserMedia.
419
421
prevMedia . participant . next ( participant ) ;
420
422
}
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
+ }
421
431
}
422
432
yield [
423
433
indexedMediaId ,
@@ -483,7 +493,7 @@ export class CallViewModel extends ViewModel {
483
493
nonMemberId ,
484
494
undefined ,
485
495
participant ,
486
- this . encrypted ,
496
+ this . encryptionSystem ,
487
497
this . matrixRTCSession ,
488
498
) ,
489
499
] ;
0 commit comments