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
This commit is contained in:
Julius Marminge committed 2026-02-15 15:33:18 -08:00
1 parent 00d7519728
commit 59b1d5d20f
3 files changed
+17 -1

No files matched your search

+1
View File
@@ -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,
});
}
+15
View File
@@ -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"));
});
});
+1 -1
View File
@@ -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);
}