From 968de5eeebd28958780f4f982fac49b510019c43 Mon Sep 17 00:00:00 2001 From: Hugh Nimmo-Smith Date: Mon, 2 Dec 2024 14:00:12 +0000 Subject: [PATCH] Use named object instead of unnamed array for spotlightAndPip --- src/state/CallViewModel.ts | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/src/state/CallViewModel.ts b/src/state/CallViewModel.ts index b3e62e82..eb81304a 100644 --- a/src/state/CallViewModel.ts +++ b/src/state/CallViewModel.ts @@ -630,17 +630,21 @@ export class CallViewModel extends ViewModel { }), ); - private readonly spotlightAndPip: Observable< - [Observable, Observable] - > = this.screenShares.pipe( + private readonly spotlightAndPip: Observable<{ + spotlight: Observable; + pip: Observable; + }> = this.screenShares.pipe( map((screenShares) => screenShares.length > 0 - ? ([of(screenShares.map((m) => m.vm)), this.spotlightSpeaker] as const) - : ([ - this.spotlightSpeaker.pipe( + ? { + spotlight: of(screenShares.map((m) => m.vm)), + pip: this.spotlightSpeaker, + } + : { + spotlight: this.spotlightSpeaker.pipe( map((speaker) => (speaker ? [speaker] : [])), ), - this.spotlightSpeaker.pipe( + pip: this.spotlightSpeaker.pipe( switchMap((speaker) => speaker ? speaker.local @@ -667,13 +671,13 @@ export class CallViewModel extends ViewModel { : of(null), ), ), - ] as const), + }, ), ); private readonly spotlight: Observable = this.spotlightAndPip.pipe( - switchMap(([spotlight]) => spotlight), + switchMap(({ spotlight }) => spotlight), this.scope.state(), ); @@ -686,7 +690,7 @@ export class CallViewModel extends ViewModel { ); private readonly pip: Observable = - this.spotlightAndPip.pipe(switchMap(([, pip]) => pip)); + this.spotlightAndPip.pipe(switchMap(({ pip }) => pip)); private readonly pipEnabled: Observable = setPipEnabled.pipe( startWith(false),