@@ -672,16 +672,6 @@ export class CallViewModel extends ViewModel {
672672 this . gridModeUserSelection . next ( value ) ;
673673 }
674674
675- private readonly oneOnOne : Observable < boolean > = combineLatest (
676- [ this . grid , this . screenShares ] ,
677- ( grid , screenShares ) =>
678- grid . length == 2 &&
679- // There might not be a remote tile if only the local user is in the call
680- // and they're using the duplicate tiles option
681- grid . some ( ( vm ) => ! vm . local ) &&
682- screenShares . length === 0 ,
683- ) ;
684-
685675 private readonly gridLayout : Observable < LayoutMedia > = combineLatest (
686676 [ this . grid , this . spotlight ] ,
687677 ( grid , spotlight ) => ( {
@@ -714,13 +704,22 @@ export class CallViewModel extends ViewModel {
714704 pip : pip ?? undefined ,
715705 } ) ) ;
716706
717- private readonly oneOnOneLayout : Observable < LayoutMedia > =
707+ private readonly oneOnOneLayout : Observable < LayoutMedia | null > =
718708 this . mediaItems . pipe (
719- map ( ( grid ) => ( {
720- type : "one-on-one" ,
721- local : grid . find ( ( vm ) => vm . vm . local ) ! . vm as LocalUserMediaViewModel ,
722- remote : grid . find ( ( vm ) => ! vm . vm . local ) ! . vm as RemoteUserMediaViewModel ,
723- } ) ) ,
709+ map ( ( mediaItems ) => {
710+ if ( mediaItems . length !== 2 ) return null ;
711+ const local = mediaItems . find ( ( vm ) => vm . vm . local ) !
712+ . vm as LocalUserMediaViewModel ;
713+ const remote = mediaItems . find ( ( vm ) => ! vm . vm . local ) ?. vm as
714+ | RemoteUserMediaViewModel
715+ | undefined ;
716+ // There might not be a remote tile if there are screen shares, or if
717+ // only the local user is in the call and they're using the duplicate
718+ // tiles option
719+ if ( remote === undefined ) return null ;
720+
721+ return { type : "one-on-one" , local, remote } ;
722+ } ) ,
724723 ) ;
725724
726725 private readonly pipLayout : Observable < LayoutMedia > = this . spotlight . pipe (
@@ -738,9 +737,9 @@ export class CallViewModel extends ViewModel {
738737 switchMap ( ( gridMode ) => {
739738 switch ( gridMode ) {
740739 case "grid" :
741- return this . oneOnOne . pipe (
740+ return this . oneOnOneLayout . pipe (
742741 switchMap ( ( oneOnOne ) =>
743- oneOnOne ? this . oneOnOneLayout : this . gridLayout ,
742+ oneOnOne === null ? this . gridLayout : of ( oneOnOne ) ,
744743 ) ,
745744 ) ;
746745 case "spotlight" :
@@ -755,20 +754,20 @@ export class CallViewModel extends ViewModel {
755754 } ) ,
756755 ) ;
757756 case "narrow" :
758- return this . oneOnOne . pipe (
757+ return this . oneOnOneLayout . pipe (
759758 switchMap ( ( oneOnOne ) =>
760- oneOnOne
761- ? // The expanded spotlight layout makes for a better one-on-one
762- // experience in narrow windows
763- this . spotlightExpandedLayout
764- : combineLatest (
759+ oneOnOne === null
760+ ? combineLatest (
765761 [ this . grid , this . spotlight ] ,
766762 ( grid , spotlight ) =>
767763 grid . length > smallMobileCallThreshold ||
768764 spotlight . some ( ( vm ) => vm instanceof ScreenShareViewModel )
769765 ? this . spotlightPortraitLayout
770766 : this . gridLayout ,
771- ) . pipe ( switchAll ( ) ) ,
767+ ) . pipe ( switchAll ( ) )
768+ : // The expanded spotlight layout makes for a better one-on-one
769+ // experience in narrow windows
770+ this . spotlightExpandedLayout ,
772771 ) ,
773772 ) ;
774773 case "flat" :
0 commit comments