From 59b1d5d20fbe254e6d0e08eaa5a5801ed5ea3830 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Sun, 15 Feb 2026 15:33:18 -0800 Subject: [PATCH] Prevent config refetches and tighten Windows platform detection - set server config query `staleTime` to `Infinity` to avoid unnecessary refetches - narrow `isWindowsPlatform` matching to Windows-prefixed identifiers - add unit tests for Windows and non-Windows platform cases --- apps/web/src/lib/serverReactQuery.ts | 1 + apps/web/src/lib/utils.test.ts | 15 +++++++++++++++ apps/web/src/lib/utils.ts | 2 +- 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 apps/web/src/lib/utils.test.ts diff --git a/apps/web/src/lib/serverReactQuery.ts b/apps/web/src/lib/serverReactQuery.ts index 2da9e3b0cd..8324cd33ef 100644 --- a/apps/web/src/lib/serverReactQuery.ts +++ b/apps/web/src/lib/serverReactQuery.ts @@ -16,5 +16,6 @@ export function serverConfigQueryOptions(api: NativeApi | undefined) { return api.server.getConfig(); }, enabled: !!api && !!api.server && typeof api.server.getConfig === "function", + staleTime: Infinity, }); } diff --git a/apps/web/src/lib/utils.test.ts b/apps/web/src/lib/utils.test.ts new file mode 100644 index 0000000000..017b6bee07 --- /dev/null +++ b/apps/web/src/lib/utils.test.ts @@ -0,0 +1,15 @@ +import { assert, describe, it } from "vitest"; + +import { isWindowsPlatform } from "./utils"; + +describe("isWindowsPlatform", () => { + it("matches Windows platform identifiers", () => { + assert.isTrue(isWindowsPlatform("Win32")); + assert.isTrue(isWindowsPlatform("Windows")); + assert.isTrue(isWindowsPlatform("windows_nt")); + }); + + it("does not match darwin", () => { + assert.isFalse(isWindowsPlatform("darwin")); + }); +}); diff --git a/apps/web/src/lib/utils.ts b/apps/web/src/lib/utils.ts index c9a08957aa..d9d5575a5d 100644 --- a/apps/web/src/lib/utils.ts +++ b/apps/web/src/lib/utils.ts @@ -10,5 +10,5 @@ export function isMacPlatform(platform: string): boolean { } export function isWindowsPlatform(platform: string): boolean { - return /win|windows/i.test(platform); + return /^win(dows)?/i.test(platform); }