mirror of
https://github.com/vector-im/element-call.git
synced 2026-07-12 18:39:19 +00:00
Avoid case of one-to-one layout with missing local or remote
This commit is contained in:
@@ -797,16 +797,26 @@ export class CallViewModel extends ViewModel {
|
|||||||
this.gridModeUserSelection.next(value);
|
this.gridModeUserSelection.next(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
private readonly oneOnOne: Observable<boolean> = combineLatest(
|
private readonly oneOnOne: Observable<
|
||||||
[this.grid, this.screenShares],
|
| { local: LocalUserMediaViewModel; remote: RemoteUserMediaViewModel }
|
||||||
(grid, screenShares) =>
|
| undefined
|
||||||
grid.length == 2 &&
|
> = combineLatest([this.grid, this.screenShares], (grid, screenShares) => {
|
||||||
// There might not be a remote tile if only the local user is in the call
|
if (grid.length !== 2 || screenShares.length !== 0) {
|
||||||
// and they're using the duplicate tiles option
|
return undefined;
|
||||||
grid.some((vm) => !vm.local) &&
|
}
|
||||||
grid.some((vm) => vm.local) &&
|
|
||||||
screenShares.length === 0,
|
const local = grid.find((vm) => vm.local);
|
||||||
);
|
const remote = grid.find((vm) => !vm.local);
|
||||||
|
|
||||||
|
if (!local || !remote) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
local,
|
||||||
|
remote,
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
private readonly gridLayout: Observable<LayoutMedia> = combineLatest(
|
private readonly gridLayout: Observable<LayoutMedia> = combineLatest(
|
||||||
[this.grid, this.spotlight],
|
[this.grid, this.spotlight],
|
||||||
@@ -842,36 +852,6 @@ export class CallViewModel extends ViewModel {
|
|||||||
pip: pip ?? undefined,
|
pip: pip ?? undefined,
|
||||||
}));
|
}));
|
||||||
|
|
||||||
private readonly oneOnOneLayout: Observable<LayoutMedia> =
|
|
||||||
this.mediaItems.pipe(
|
|
||||||
map((grid) => {
|
|
||||||
const local = grid.find((vm) => vm.vm.local)?.vm as
|
|
||||||
| LocalUserMediaViewModel
|
|
||||||
| undefined;
|
|
||||||
const remote = grid.find((vm) => !vm.vm.local)?.vm as
|
|
||||||
| RemoteUserMediaViewModel
|
|
||||||
| undefined;
|
|
||||||
if (!local || !remote) {
|
|
||||||
logger.warn(
|
|
||||||
`Falling back to grid layout for one-on-one layout with missing media: local=${!!local} remote=${!!remote}`,
|
|
||||||
);
|
|
||||||
return {
|
|
||||||
type: "grid",
|
|
||||||
grid: grid.filter(
|
|
||||||
(m) =>
|
|
||||||
m instanceof LocalUserMediaViewModel ||
|
|
||||||
m instanceof RemoteUserMediaViewModel,
|
|
||||||
),
|
|
||||||
};
|
|
||||||
}
|
|
||||||
return {
|
|
||||||
type: "one-on-one",
|
|
||||||
local,
|
|
||||||
remote,
|
|
||||||
};
|
|
||||||
}),
|
|
||||||
);
|
|
||||||
|
|
||||||
private readonly pipLayout: Observable<LayoutMedia> = this.spotlight.pipe(
|
private readonly pipLayout: Observable<LayoutMedia> = this.spotlight.pipe(
|
||||||
map((spotlight) => ({ type: "pip", spotlight })),
|
map((spotlight) => ({ type: "pip", spotlight })),
|
||||||
);
|
);
|
||||||
@@ -888,8 +868,15 @@ export class CallViewModel extends ViewModel {
|
|||||||
switch (gridMode) {
|
switch (gridMode) {
|
||||||
case "grid":
|
case "grid":
|
||||||
return this.oneOnOne.pipe(
|
return this.oneOnOne.pipe(
|
||||||
switchMap((oneOnOne) =>
|
switchMap(
|
||||||
oneOnOne ? this.oneOnOneLayout : this.gridLayout,
|
(oneOnOne): Observable<LayoutMedia> =>
|
||||||
|
oneOnOne
|
||||||
|
? of({
|
||||||
|
type: "one-on-one",
|
||||||
|
local: oneOnOne.local,
|
||||||
|
remote: oneOnOne.remote,
|
||||||
|
})
|
||||||
|
: this.gridLayout,
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
case "spotlight":
|
case "spotlight":
|
||||||
|
|||||||
Reference in New Issue
Block a user