| author | |
| committer | |
| log | 8dd107429e92dfcb52d8afb46e2a01517840fabc |
| tree | 72ffa99459ca4bc5bcb27c1ce04631521a842cf2 |
| parent | 1269b5258097d75f4cb413a0612570a106e32426 |
- 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 cases3 files changed, 17 insertions(+), 1 deletions(-)
apps/web/src/lib/serverReactQuery.ts+1| ... | ... | @@ -16,5 +16,6 @@ export function serverConfigQueryOptions(api: NativeApi | undefined) { |
| 16 | 16 | return api.server.getConfig(); |
| 17 | 17 | }, |
| 18 | 18 | enabled: !!api && !!api.server && typeof api.server.getConfig === "function", |
| 19 | staleTime: Infinity, | |
| 19 | 20 | }); |
| 20 | 21 | } |
apps/web/src/lib/utils.test.ts created+15| ... | ... | @@ -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+1-1| ... | ... | @@ -10,5 +10,5 @@ export function isMacPlatform(platform: string): boolean { |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | 12 | export function isWindowsPlatform(platform: string): boolean { |
| 13 | return /win|windows/i.test(platform); | |
| 13 | return /^win(dows)?/i.test(platform); | |
| 14 | 14 | } |