From be7407ea3d7fc060538f8c3e52b2aa2bb4ea25bf Mon Sep 17 00:00:00 2001 From: Valere Date: Thu, 4 Dec 2025 09:37:07 +0100 Subject: [PATCH] review: quick renaming --- src/state/CallViewModel/LayoutSwitch.test.ts | 17 +++++++++++++++ src/state/CallViewModel/LayoutSwitch.ts | 22 ++++++++++---------- 2 files changed, 28 insertions(+), 11 deletions(-) diff --git a/src/state/CallViewModel/LayoutSwitch.test.ts b/src/state/CallViewModel/LayoutSwitch.test.ts index c1941eb8..ae5a3896 100644 --- a/src/state/CallViewModel/LayoutSwitch.test.ts +++ b/src/state/CallViewModel/LayoutSwitch.test.ts @@ -144,6 +144,23 @@ test("Should switch back to grid mode when the remote screen share ends", () => }); }); +test("can auto-switch to spotlight again after first screen share ends", () => { + withTestScheduler(({ cold, behavior, expectObservable }): void => { + const shareMarble = "ftft"; + const gridsMarble = "gsgs"; + const { gridMode$ } = createLayoutModeSwitch( + scope, + behavior("n", { n: "normal" }), + cold(shareMarble, { f: false, t: true }), + ); + + expectObservable(gridMode$).toBe(gridsMarble, { + g: "grid", + s: "spotlight", + }); + }); +}); + test("can switch manually to grid after screen share while manually in spotlight", () => { withTestScheduler(({ cold, behavior, schedule, expectObservable }): void => { // Initially, no one is sharing. Then the user manually switches to diff --git a/src/state/CallViewModel/LayoutSwitch.ts b/src/state/CallViewModel/LayoutSwitch.ts index 65c6bcb1..3ad93204 100644 --- a/src/state/CallViewModel/LayoutSwitch.ts +++ b/src/state/CallViewModel/LayoutSwitch.ts @@ -64,10 +64,10 @@ export function createLayoutModeSwitch( /** Remember if the change was user driven or not */ hasAutoSwitched: boolean; /** To know if it is new screen share or an already handled */ - prevShare: boolean; + hasScreenShares: boolean; } >( - (acc, [userSelection, hasScreenShares, windowMode]) => { + (prev, [userSelection, hasScreenShares, windowMode]) => { const isFlatMode = windowMode === "flat"; // Always force spotlight in flat mode, grid layout is not supported @@ -78,8 +78,8 @@ export function createLayoutModeSwitch( logger.debug(`Forcing spotlight mode, windowMode=${windowMode}`); return { mode: "spotlight", - hasAutoSwitched: acc.hasAutoSwitched, - prevShare: hasScreenShares, + hasAutoSwitched: prev.hasAutoSwitched, + hasScreenShares, }; } @@ -88,8 +88,8 @@ export function createLayoutModeSwitch( if (userSelection === "spotlight") { return { mode: "spotlight", - hasAutoSwitched: acc.hasAutoSwitched, - prevShare: hasScreenShares, + hasAutoSwitched: prev.hasAutoSwitched, + hasScreenShares, }; } @@ -97,12 +97,12 @@ export function createLayoutModeSwitch( // auto-switch to spotlight mode for better experience. // But we only do it once, if the user switches back to grid mode, // we respect that choice until they explicitly change it again. - const isNewShare = hasScreenShares && !acc.prevShare; - if (isNewShare && !acc.hasAutoSwitched) { + const isNewShare = hasScreenShares && !prev.hasScreenShares; + if (isNewShare && !prev.hasAutoSwitched) { return { mode: "spotlight", hasAutoSwitched: true, - prevShare: true, + hasScreenShares: true, }; } @@ -112,11 +112,11 @@ export function createLayoutModeSwitch( return { mode: "grid", hasAutoSwitched: false, - prevShare: hasScreenShares, + hasScreenShares, }; }, // initial value - { mode: "grid", hasAutoSwitched: false, prevShare: false }, + { mode: "grid", hasAutoSwitched: false, hasScreenShares: false }, ), map(({ mode }) => mode), ),