Refactor spotlightAndPip into spotlight and pip

This commit is contained in:
Hugh Nimmo-Smith
2024-12-02 14:10:31 +00:00
parent 968de5eeeb
commit 33f398ddcf

View File

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