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:
1 parent
1269b52580
commit
8dd107429e
3 files changed
+17
-1
No files matched your search
@@ -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,
|
||||
});
|
||||
}
|
||||
@@ -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"));
|
||||
});
|
||||
});
|
||||
@@ -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);
|
||||
}
|
||||
Reference in new issue
Block a user