diff --git a/src/state/CallViewModel.ts b/src/state/CallViewModel.ts index 5feb6585d..1996f657f 100644 --- a/src/state/CallViewModel.ts +++ b/src/state/CallViewModel.ts @@ -45,7 +45,6 @@ import { scan, shareReplay, startWith, - switchAll, switchMap, throttleTime, timer, @@ -491,39 +490,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.