diff --git a/desktop/ui/src/hooks/useIsWindows10.ts b/desktop/ui/src/hooks/useIsWindows10.ts index 9c0c57ec..07c1e3a7 100644 --- a/desktop/ui/src/hooks/useIsWindows10.ts +++ b/desktop/ui/src/hooks/useIsWindows10.ts @@ -1,4 +1,4 @@ -import { useState, useEffect } from "react"; +import { useState } from "react"; import { version } from "@tauri-apps/plugin-os"; /** @@ -7,20 +7,17 @@ import { version } from "@tauri-apps/plugin-os"; * Windows 11 also reports as "10.0" but with build number >= 22000. */ export function useIsWindows10(): boolean | null { - const [isWindows10, setIsWindows10] = useState(null); - - useEffect(() => { + const [isWindows10] = useState(() => { // Windows version format: "10.0.19045" (Win10) or "10.0.22631" (Win11) // Windows 11 has build number >= 22000 const parts = version().split("."); if (parts.length >= 3) { const buildNumber = parseInt(parts[2], 10); // Windows 10 has build numbers below 22000 - setIsWindows10(!isNaN(buildNumber) && buildNumber < 22000); - } else { - setIsWindows10(false); + return !isNaN(buildNumber) && buildNumber < 22000; } - }, []); + return false; + }); return isWindows10; } diff --git a/desktop/ui/src/pages/AddDrive.tsx b/desktop/ui/src/pages/AddDrive.tsx index 8543d284..be8aa57f 100644 --- a/desktop/ui/src/pages/AddDrive.tsx +++ b/desktop/ui/src/pages/AddDrive.tsx @@ -129,7 +129,9 @@ export default function AddDrive({ mode = "add" }: AddDriveProps) { pkceSessionRef.current.callbackData = callbackData; // Transition to final setup page - callbackData.name && setDriveName(callbackData.name); + if (callbackData.name) { + setDriveName(callbackData.name); + } setPageState("final_setup"); }).then((fn) => { unlisten = fn;