diff --git a/frontend/src/stores/playing.ts b/frontend/src/stores/playing.ts index e265cb2da..d3c346ac5 100644 --- a/frontend/src/stores/playing.ts +++ b/frontend/src/stores/playing.ts @@ -4,6 +4,9 @@ export default defineStore("playing", { state: () => ({ playing: false, fullScreen: false, + // True while a player's running stage covers the viewport; the v2 + // AppLayout unmounts the nav chrome and zeroes the nav-height tokens. + stageActive: false, }), actions: { @@ -13,5 +16,8 @@ export default defineStore("playing", { setFullScreen(fullScreen: boolean) { this.fullScreen = fullScreen; }, + setStageActive(stageActive: boolean) { + this.stageActive = stageActive; + }, }, }); diff --git a/frontend/src/v2/components/Player/PlayerShell.test.ts b/frontend/src/v2/components/Player/PlayerShell.test.ts index cbb364d29..518ccecae 100644 --- a/frontend/src/v2/components/Player/PlayerShell.test.ts +++ b/frontend/src/v2/components/Player/PlayerShell.test.ts @@ -3,12 +3,16 @@ import { beforeEach, describe, expect, it, vi } from "vitest"; import type { SimpleRom } from "@/stores/roms"; import PlayerShell from "./PlayerShell.vue"; -const mocks = vi.hoisted(() => ({ push: vi.fn() })); +const mocks = vi.hoisted(() => ({ push: vi.fn(), setStageActive: vi.fn() })); vi.mock("vue-i18n", () => ({ useI18n: () => ({ t: (key: string) => key }), })); +vi.mock("@/stores/playing", () => ({ + default: () => ({ setStageActive: mocks.setStageActive }), +})); + vi.mock("vue-router", () => ({ useRouter: () => ({ push: mocks.push }), })); @@ -59,6 +63,7 @@ function mountShell( beforeEach(() => { mocks.push.mockReset(); + mocks.setStageActive.mockReset(); }); describe("PlayerShell", () => { @@ -133,4 +138,16 @@ describe("PlayerShell", () => { wrapper.get(".r-v2-player__quit").attributes("disabled"), ).toBeDefined(); }); + + it("mirrors the running stage into the global chrome flag", async () => { + const wrapper = mountShell({ running: true }); + expect(mocks.setStageActive).toHaveBeenLastCalledWith(true); + + await wrapper.setProps({ running: false }); + expect(mocks.setStageActive).toHaveBeenLastCalledWith(false); + + await wrapper.setProps({ running: true }); + wrapper.unmount(); + expect(mocks.setStageActive).toHaveBeenLastCalledWith(false); + }); }); diff --git a/frontend/src/v2/components/Player/PlayerShell.vue b/frontend/src/v2/components/Player/PlayerShell.vue index 0add5949c..2eb0095ba 100644 --- a/frontend/src/v2/components/Player/PlayerShell.vue +++ b/frontend/src/v2/components/Player/PlayerShell.vue @@ -9,6 +9,7 @@ import { useI18n } from "vue-i18n"; import type { DetailedRom, SimpleRom } from "@/stores/roms"; import GameCover from "@/v2/components/shared/GameCover.vue"; import { usePlayerNav } from "@/v2/composables/usePlayerNav"; +import { useStageActive } from "@/v2/composables/useStageActive"; interface Props { /** Full rom once loaded, else the cover-only seed during the morph-in. */ @@ -34,6 +35,9 @@ const { backToRom, backToPlatform } = usePlayerNav( props.romId, () => props.heroRom?.platform_id, ); +// The shell owns the running flag, so it also drives the chrome unmount +// for every player built on it. +useStageActive(() => props.running);