Use named object instead of unnamed array for spotlightAndPip

This commit is contained in:
Hugh Nimmo-Smith
2024-12-02 14:00:12 +00:00
parent 3d0bfaefe8
commit 968de5eeeb

View File

@@ -630,17 +630,21 @@ export class CallViewModel extends ViewModel {
}), }),
); );
private readonly spotlightAndPip: Observable< private readonly spotlightAndPip: Observable<{
[Observable<MediaViewModel[]>, Observable<UserMediaViewModel | null>] spotlight: Observable<MediaViewModel[]>;
> = this.screenShares.pipe( pip: Observable<UserMediaViewModel | null>;
}> = this.screenShares.pipe(
map((screenShares) => map((screenShares) =>
screenShares.length > 0 screenShares.length > 0
? ([of(screenShares.map((m) => m.vm)), this.spotlightSpeaker] as const) ? {
: ([ spotlight: of(screenShares.map((m) => m.vm)),
this.spotlightSpeaker.pipe( pip: this.spotlightSpeaker,
}
: {
spotlight: this.spotlightSpeaker.pipe(
map((speaker) => (speaker ? [speaker] : [])), map((speaker) => (speaker ? [speaker] : [])),
), ),
this.spotlightSpeaker.pipe( pip: this.spotlightSpeaker.pipe(
switchMap((speaker) => switchMap((speaker) =>
speaker speaker
? speaker.local ? speaker.local
@@ -667,13 +671,13 @@ export class CallViewModel extends ViewModel {
: of(null), : of(null),
), ),
), ),
] as const), },
), ),
); );
private readonly spotlight: Observable<MediaViewModel[]> = private readonly spotlight: Observable<MediaViewModel[]> =
this.spotlightAndPip.pipe( this.spotlightAndPip.pipe(
switchMap(([spotlight]) => spotlight), switchMap(({ spotlight }) => spotlight),
this.scope.state(), this.scope.state(),
); );
@@ -686,7 +690,7 @@ export class CallViewModel extends ViewModel {
); );
private readonly pip: Observable<UserMediaViewModel | null> = private readonly pip: Observable<UserMediaViewModel | null> =
this.spotlightAndPip.pipe(switchMap(([, pip]) => pip)); this.spotlightAndPip.pipe(switchMap(({ pip }) => pip));
private readonly pipEnabled: Observable<boolean> = setPipEnabled.pipe( private readonly pipEnabled: Observable<boolean> = setPipEnabled.pipe(
startWith(false), startWith(false),