This commit is contained in:
Hugh Nimmo-Smith
2024-11-14 13:51:49 +00:00
parent eafd8fd8b6
commit f6a641b478

View File

@@ -379,7 +379,6 @@ export class CallViewModel extends ViewModel {
/** /**
* The raw list of RemoteParticipants as reported by LiveKit * The raw list of RemoteParticipants as reported by LiveKit
*/ */
private readonly rawRemoteParticipants: Observable<RemoteParticipant[]> = private readonly rawRemoteParticipants: Observable<RemoteParticipant[]> =
connectedParticipantsObserver(this.livekitRoom).pipe(this.scope.state()); connectedParticipantsObserver(this.livekitRoom).pipe(this.scope.state());
@@ -573,9 +572,8 @@ export class CallViewModel extends ViewModel {
this.scope.state(), this.scope.state(),
); );
private readonly spotlightSpeaker: Observable< private readonly spotlightSpeaker: Observable<UserMediaViewModel | null> =
UserMediaViewModel | undefined this.userMedia.pipe(
> = this.userMedia.pipe(
switchMap((mediaItems) => switchMap((mediaItems) =>
mediaItems.length === 0 mediaItems.length === 0
? of([]) ? of([])
@@ -606,7 +604,7 @@ export class CallViewModel extends ViewModel {
}, },
null, null,
), ),
map((speaker) => speaker?.vm), map((speaker) => speaker?.vm ?? null),
this.scope.state(), this.scope.state(),
); );
@@ -647,7 +645,7 @@ export class CallViewModel extends ViewModel {
); );
private readonly spotlightAndPip: Observable< private readonly spotlightAndPip: Observable<
[Observable<MediaViewModel[]>, Observable<UserMediaViewModel | undefined>] [Observable<MediaViewModel[]>, Observable<UserMediaViewModel | null>]
> = this.screenShares.pipe( > = this.screenShares.pipe(
map((screenShares) => map((screenShares) =>
screenShares.length > 0 screenShares.length > 0
@@ -660,7 +658,7 @@ export class CallViewModel extends ViewModel {
switchMap((speaker) => switchMap((speaker) =>
speaker speaker
? speaker.local ? speaker.local
? of(undefined) ? of(null)
: this.mediaItems.pipe( : this.mediaItems.pipe(
switchMap((mediaItems) => { switchMap((mediaItems) => {
const localUserMedia = mediaItems.find( const localUserMedia = mediaItems.find(
@@ -671,11 +669,11 @@ export class CallViewModel extends ViewModel {
map((alwaysShow) => map((alwaysShow) =>
alwaysShow ? localUserMedia : undefined, alwaysShow ? localUserMedia : undefined,
), ),
) ?? of(undefined) ) ?? of(null)
); );
}), }),
) )
: of(undefined), : of(null),
), ),
), ),
] as const), ] as const),
@@ -689,12 +687,14 @@ export class CallViewModel extends ViewModel {
); );
private readonly hasRemoteScreenShares: Observable<boolean> = private readonly hasRemoteScreenShares: Observable<boolean> =
this.screenShares.pipe( this.spotlight.pipe(
map((ms) => ms.some((m) => !m.vm.local)), map((spotlight) =>
spotlight.some((vm) => !vm.local && vm instanceof ScreenShareViewModel),
),
distinctUntilChanged(), distinctUntilChanged(),
); );
private readonly pip: Observable<UserMediaViewModel | undefined> = 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(
@@ -780,8 +780,7 @@ export class CallViewModel extends ViewModel {
type: "spotlight-landscape", type: "spotlight-landscape",
spotlight, spotlight,
grid, grid,
}), }));
);
private readonly spotlightPortraitLayoutMedia: Observable<SpotlightPortraitLayoutMedia> = private readonly spotlightPortraitLayoutMedia: Observable<SpotlightPortraitLayoutMedia> =
combineLatest([this.grid, this.spotlight], (grid, spotlight) => ({ combineLatest([this.grid, this.spotlight], (grid, spotlight) => ({