Skip to content

Commit 59b1d5d

Browse files
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
1 parent 00d7519 commit 59b1d5d

3 files changed

Lines changed: 17 additions & 1 deletion

File tree

‎apps/web/src/lib/serverReactQuery.ts‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ export function serverConfigQueryOptions(api: NativeApi | undefined) {
1616
return api.server.getConfig();
1717
},
1818
enabled: !!api && !!api.server && typeof api.server.getConfig === "function",
19+
staleTime: Infinity,
1920
});
2021
}

‎apps/web/src/lib/utils.test.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import { assert, describe, it } from "vitest";
2+
3+
import { isWindowsPlatform } from "./utils";
4+
5+
describe("isWindowsPlatform", () => {
6+
it("matches Windows platform identifiers", () => {
7+
assert.isTrue(isWindowsPlatform("Win32"));
8+
assert.isTrue(isWindowsPlatform("Windows"));
9+
assert.isTrue(isWindowsPlatform("windows_nt"));
10+
});
11+
12+
it("does not match darwin", () => {
13+
assert.isFalse(isWindowsPlatform("darwin"));
14+
});
15+
});

‎apps/web/src/lib/utils.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@ export function isMacPlatform(platform: string): boolean {
1010
}
1111

1212
export function isWindowsPlatform(platform: string): boolean {
13-
return /win|windows/i.test(platform);
13+
return /^win(dows)?/i.test(platform);
1414
}

0 commit comments

Comments
 (0)