Merge pull request #2752 from robintown/one-on-one-crash
Make one-on-one layout less prone to crashing
This commit is contained in:
@@ -672,16 +672,6 @@ export class CallViewModel extends ViewModel {
|
|||||||
this.gridModeUserSelection.next(value);
|
this.gridModeUserSelection.next(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly oneOnOne: Observable<boolean> = combineLatest(
|
|
||||||
[this.grid, this.screenShares],
|
|
||||||
(grid, screenShares) =>
|
|
||||||
grid.length == 2 &&
|
|
||||||
// There might not be a remote tile if only the local user is in the call
|
|
||||||
// and they're using the duplicate tiles option
|
|
||||||
grid.some((vm) => !vm.local) &&
|
|
||||||
screenShares.length === 0,
|
|
||||||
);
|
|
||||||
|
|
||||||
private readonly gridLayout: Observable<LayoutMedia> = combineLatest(
|
private readonly gridLayout: Observable<LayoutMedia> = combineLatest(
|
||||||
[this.grid, this.spotlight],
|
[this.grid, this.spotlight],
|
||||||
(grid, spotlight) => ({
|
(grid, spotlight) => ({
|
||||||
@@ -714,13 +704,22 @@ export class CallViewModel extends ViewModel {
|
|||||||
pip: pip ?? undefined,
|
pip: pip ?? undefined,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
private readonly oneOnOneLayout: Observable<LayoutMedia> =
|
private readonly oneOnOneLayout: Observable<LayoutMedia | null> =
|
||||||
this.mediaItems.pipe(
|
this.mediaItems.pipe(
|
||||||
map((grid) => ({
|
map((mediaItems) => {
|
||||||
type: "one-on-one",
|
if (mediaItems.length !== 2) return null;
|
||||||
local: grid.find((vm) => vm.vm.local)!.vm as LocalUserMediaViewModel,
|
const local = mediaItems.find((vm) => vm.vm.local)!
|
||||||
remote: grid.find((vm) => !vm.vm.local)!.vm as RemoteUserMediaViewModel,
|
.vm as LocalUserMediaViewModel;
|
||||||
})),
|
const remote = mediaItems.find((vm) => !vm.vm.local)?.vm as
|
||||||
|
| RemoteUserMediaViewModel
|
||||||
|
| undefined;
|
||||||
|
// There might not be a remote tile if there are screen shares, or if
|
||||||
|
// only the local user is in the call and they're using the duplicate
|
||||||
|
// tiles option
|
||||||
|
if (remote === undefined) return null;
|
||||||
|
|
||||||
|
return { type: "one-on-one", local, remote };
|
||||||
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
private readonly pipLayout: Observable<LayoutMedia> = this.spotlight.pipe(
|
private readonly pipLayout: Observable<LayoutMedia> = this.spotlight.pipe(
|
||||||
@@ -738,9 +737,9 @@ export class CallViewModel extends ViewModel {
|
|||||||
switchMap((gridMode) => {
|
switchMap((gridMode) => {
|
||||||
switch (gridMode) {
|
switch (gridMode) {
|
||||||
case "grid":
|
case "grid":
|
||||||
return this.oneOnOne.pipe(
|
return this.oneOnOneLayout.pipe(
|
||||||
switchMap((oneOnOne) =>
|
switchMap((oneOnOne) =>
|
||||||
oneOnOne ? this.oneOnOneLayout : this.gridLayout,
|
oneOnOne === null ? this.gridLayout : of(oneOnOne),
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
case "spotlight":
|
case "spotlight":
|
||||||
@@ -755,20 +754,20 @@ export class CallViewModel extends ViewModel {
|
|||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
case "narrow":
|
case "narrow":
|
||||||
return this.oneOnOne.pipe(
|
return this.oneOnOneLayout.pipe(
|
||||||
switchMap((oneOnOne) =>
|
switchMap((oneOnOne) =>
|
||||||
oneOnOne
|
oneOnOne === null
|
||||||
? // The expanded spotlight layout makes for a better one-on-one
|
? combineLatest(
|
||||||
// experience in narrow windows
|
|
||||||
this.spotlightExpandedLayout
|
|
||||||
: combineLatest(
|
|
||||||
[this.grid, this.spotlight],
|
[this.grid, this.spotlight],
|
||||||
(grid, spotlight) =>
|
(grid, spotlight) =>
|
||||||
grid.length > smallMobileCallThreshold ||
|
grid.length > smallMobileCallThreshold ||
|
||||||
spotlight.some((vm) => vm instanceof ScreenShareViewModel)
|
spotlight.some((vm) => vm instanceof ScreenShareViewModel)
|
||||||
? this.spotlightPortraitLayout
|
? this.spotlightPortraitLayout
|
||||||
: this.gridLayout,
|
: this.gridLayout,
|
||||||
).pipe(switchAll()),
|
).pipe(switchAll())
|
||||||
|
: // The expanded spotlight layout makes for a better one-on-one
|
||||||
|
// experience in narrow windows
|
||||||
|
this.spotlightExpandedLayout,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
case "flat":
|
case "flat":
|
||||||
|
|||||||
Reference in New Issue
Block a user