diff options
| author | Adam Malczewski <[email protected]> | 2026-10-21 01:04:35 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-10-21 01:04:35 +0900 |
| commit | c61b4d66921e7fe5d7d1e2a988e96785f6aedd9f (patch) | |
| tree | 8130a35661a66d28197f5f52fff036a6be523656 /src/app | |
| parent | b3a539260aa15efd197ce06c1073f0f25fee0c15 (diff) | |
| download | dispatch-web-c61b4d66921e7fe5d7d1e2a988e96785f6aedd9f.tar.gz dispatch-web-c61b4d66921e7fe5d7d1e2a988e96785f6aedd9f.zip | |
fix(review-1.3): render home tiles before layout revalidation
Diffstat (limited to 'src/app')
| -rw-r--r-- | src/app/store.svelte.ts | 14 | ||||
| -rw-r--r-- | src/app/store.test.ts | 23 |
2 files changed, 34 insertions, 3 deletions
diff --git a/src/app/store.svelte.ts b/src/app/store.svelte.ts index d75495a..c354e11 100644 --- a/src/app/store.svelte.ts +++ b/src/app/store.svelte.ts @@ -123,9 +123,12 @@ import { type VisionSettings, type VisionSettingsPatch, } from "../features/vision"; -import { createTileLayoutHttp } from "../features/workspaces/adapter/tile-layout-http"; -import type { TileLayoutStore } from "../features/workspaces/tile-layout-store.svelte"; -import { createTileLayoutStore } from "../features/workspaces/tile-layout-store.svelte"; +import { + createTileLayoutHttp, + createTileLayoutStore, + geometryFor, + type TileLayoutStore, +} from "../features/workspaces"; import { createPluginHost } from "./plugin-host.svelte"; import { resolveHttpUrl } from "./resolve-http-url"; import { resolveWsUrl } from "./resolve-ws-url"; @@ -816,6 +819,11 @@ export function createAppStore(opts?: CreateAppStoreOptions): AppStore { // the debounced PUT + rollback, and the offline degrade. const tileLayoutStore = createTileLayoutStore({ http: createTileLayoutHttp(httpBase, fetchImpl), + initialMode: + typeof window === "undefined" + ? "wide" + : geometryFor(window.innerWidth, window.innerHeight).mode, + storage: localStorageOpt, }); /** diff --git a/src/app/store.test.ts b/src/app/store.test.ts index bfd4039..4c530f1 100644 --- a/src/app/store.test.ts +++ b/src/app/store.test.ts @@ -234,6 +234,29 @@ describe("createAppStore", () => { store.dispose(); }); + it("probes only the portrait tile layout at boot and injects its cached document", () => { + const width = vi.spyOn(window, "innerWidth", "get").mockReturnValue(390); + const height = vi.spyOn(window, "innerHeight", "get").mockReturnValue(844); + const storage = createFakeStorage(); + const cached = { version: 2, tiles: [{ id: "a", order: 0, colSpan: 2, rowSpan: 2 }] }; + storage.setItem("dispatch.tile-layout.tall", JSON.stringify(cached)); + const fetchImpl = vi.fn(fakeFetchImpl()); + const store = createAppStore({ socketFactory: fakeSocket, fetchImpl, localStorage: storage }); + try { + expect(store.tileLayout.mode).toBe("tall"); + expect(store.tileLayout.entries).toEqual(cached.tiles); + expect( + fetchImpl.mock.calls + .map(([url]) => String(url)) + .filter((url) => url.includes("/home/tile-layout/")), + ).toEqual([expect.stringMatching(/\/home\/tile-layout\/tall$/)]); + } finally { + store.dispose(); + width.mockRestore(); + height.mockRestore(); + } + }); + it("updates catalog when catalog message arrives", () => { const ws = fakeSocket(); const store = createAppStore({ |
