Make layout reactivity a little more fine-grained

This commit is contained in:
Robin
2024-06-04 16:07:07 -04:00
parent dfda7539d6
commit 12b719da95

View File

@@ -45,7 +45,6 @@ import {
scan, scan,
shareReplay, shareReplay,
startWith, startWith,
switchAll,
switchMap, switchMap,
throttleTime, throttleTime,
timer, timer,
@@ -488,22 +487,24 @@ export class CallViewModel extends ViewModel {
this.gridModeUserSelection.next(value); this.gridModeUserSelection.next(value);
} }
public readonly layout: Observable<Layout> = combineLatest( public readonly layout: Observable<Layout> = this.windowMode.pipe(
[this.gridMode, this.windowMode], switchMap((windowMode) => {
(gridMode, windowMode) => {
switch (windowMode) { switch (windowMode) {
case "full screen": case "full screen":
throw new Error("unimplemented"); throw new Error("unimplemented");
case "pip": case "pip":
throw new Error("unimplemented"); throw new Error("unimplemented");
case "normal": { case "normal":
return this.gridMode.pipe(
switchMap((gridMode) => {
switch (gridMode) { switch (gridMode) {
case "grid": case "grid":
return combineLatest( return combineLatest(
[this.grid, this.spotlight, this.screenShares], [this.grid, this.spotlight, this.screenShares],
(grid, spotlight, screenShares): Layout => ({ (grid, spotlight, screenShares): Layout => ({
type: "grid", type: "grid",
spotlight: screenShares.length > 0 ? spotlight : undefined, spotlight:
screenShares.length > 0 ? spotlight : undefined,
grid, grid,
}), }),
); );
@@ -517,10 +518,12 @@ export class CallViewModel extends ViewModel {
}), }),
); );
} }
}),
);
} }
} }),
}, shareReplay(1),
).pipe(switchAll(), shareReplay(1)); );
/** /**
* The media tiles to be displayed in the call view. * The media tiles to be displayed in the call view.