From 12b719da95ac8221f5aa9e8f44f8a0797af4041e Mon Sep 17 00:00:00 2001 From: Robin Date: Tue, 4 Jun 2024 16:07:07 -0400 Subject: [PATCH] Make layout reactivity a little more fine-grained --- src/state/CallViewModel.ts | 59 ++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 28 deletions(-) diff --git a/src/state/CallViewModel.ts b/src/state/CallViewModel.ts index 3bbc0a2d..31a1fdb3 100644 --- a/src/state/CallViewModel.ts +++ b/src/state/CallViewModel.ts @@ -45,7 +45,6 @@ import { scan, shareReplay, startWith, - switchAll, switchMap, throttleTime, timer, @@ -488,39 +487,43 @@ export class CallViewModel extends ViewModel { this.gridModeUserSelection.next(value); } - public readonly layout: Observable = combineLatest( - [this.gridMode, this.windowMode], - (gridMode, windowMode) => { + public readonly layout: Observable = this.windowMode.pipe( + switchMap((windowMode) => { switch (windowMode) { case "full screen": throw new Error("unimplemented"); case "pip": throw new Error("unimplemented"); - case "normal": { - switch (gridMode) { - case "grid": - return combineLatest( - [this.grid, this.spotlight, this.screenShares], - (grid, spotlight, screenShares): Layout => ({ - type: "grid", - spotlight: screenShares.length > 0 ? spotlight : undefined, - grid, - }), - ); - case "spotlight": - return combineLatest( - [this.grid, this.spotlight], - (grid, spotlight): Layout => ({ - type: "spotlight", - spotlight, - grid, - }), - ); - } - } + case "normal": + return this.gridMode.pipe( + switchMap((gridMode) => { + switch (gridMode) { + case "grid": + return combineLatest( + [this.grid, this.spotlight, this.screenShares], + (grid, spotlight, screenShares): Layout => ({ + type: "grid", + spotlight: + screenShares.length > 0 ? spotlight : undefined, + grid, + }), + ); + case "spotlight": + return combineLatest( + [this.grid, this.spotlight], + (grid, spotlight): Layout => ({ + type: "spotlight", + spotlight, + grid, + }), + ); + } + }), + ); } - }, - ).pipe(switchAll(), shareReplay(1)); + }), + shareReplay(1), + ); /** * The media tiles to be displayed in the call view.