Add model for one-on-one layout

This commit is contained in:
Robin
2024-06-07 12:27:13 -04:00
parent 183d2d9050
commit e0b10d89b5
2 changed files with 30 additions and 12 deletions

View File

@@ -330,10 +330,7 @@ export const InCallView: FC<InCallViewProps> = ({
vm.layout.pipe(
map((l) => {
let makeLayout: CallLayout<Layout>;
if (
l.type === "grid" &&
!(l.grid.length === 2 && l.spotlight === undefined)
)
if (l.type === "grid")
makeLayout = makeGridLayout as CallLayout<Layout>;
else if (l.type === "spotlight")
makeLayout = makeSpotlightLayout as CallLayout<Layout>;

View File

@@ -102,6 +102,13 @@ export interface SpotlightLayout {
grid: UserMediaViewModel[];
}
export interface OneOnOneLayout {
type: "one-on-one";
spotlight?: ScreenShareViewModel[];
local: LocalUserMediaViewModel;
remote: RemoteUserMediaViewModel;
}
export interface FullScreenLayout {
type: "full screen";
spotlight: MediaViewModel[];
@@ -120,6 +127,7 @@ export interface PipLayout {
export type Layout =
| GridLayout
| SpotlightLayout
| OneOnOneLayout
| FullScreenLayout
| PipLayout;
@@ -501,14 +509,27 @@ export class CallViewModel extends ViewModel {
case "grid":
return combineLatest(
[this.grid, this.spotlight, this.screenShares],
(grid, spotlight, screenShares): Layout => ({
type: "grid",
spotlight:
screenShares.length > 0 || grid.length > 20
? spotlight
: undefined,
grid,
}),
(grid, spotlight, screenShares): Layout =>
grid.length == 2
? {
type: "one-on-one",
spotlight:
screenShares.length > 0 ? spotlight : undefined,
local: grid.find(
(vm) => vm.local,
) as LocalUserMediaViewModel,
remote: grid.find(
(vm) => !vm.local,
) as RemoteUserMediaViewModel,
}
: {
type: "grid",
spotlight:
screenShares.length > 0 || grid.length > 20
? spotlight
: undefined,
grid,
},
);
case "spotlight":
return combineLatest(