diff --git a/gui/src/components/TopBar.tsx b/gui/src/components/TopBar.tsx index 60a574857..5c54811fa 100644 --- a/gui/src/components/TopBar.tsx +++ b/gui/src/components/TopBar.tsx @@ -106,6 +106,8 @@ export function TopBar({ const unshowVersionBind = useDoubleTap(() => setShowVersionMobile(false)); useEffect(() => { + if (!isTauri) return; + const unlistenTrayClose = listen('try-close', async () => { const window = getCurrentWindow(); await window.show(); @@ -115,20 +117,18 @@ export function TopBar({ await tryCloseApp(true); }); - const unlistenCloseRequested = isTauri - ? getCurrentWindow().listen( - TauriEvent.WINDOW_CLOSE_REQUESTED, - async (data) => { - const ev = new CloseRequestedEvent(data); - ev.preventDefault(); - await tryCloseApp(); - } - ) - : undefined; + const unlistenCloseRequested = getCurrentWindow().listen( + TauriEvent.WINDOW_CLOSE_REQUESTED, + async (data) => { + const ev = new CloseRequestedEvent(data); + ev.preventDefault(); + await tryCloseApp(); + } + ); return () => { unlistenTrayClose.then((fn) => fn()); - unlistenCloseRequested?.then((fn) => fn()); + unlistenCloseRequested.then((fn) => fn()); }; }, [ config?.useTray, diff --git a/gui/src/components/onboarding/pages/body-proportions/ManualProportions.tsx b/gui/src/components/onboarding/pages/body-proportions/ManualProportions.tsx index 92ba09477..2ff3d0876 100644 --- a/gui/src/components/onboarding/pages/body-proportions/ManualProportions.tsx +++ b/gui/src/components/onboarding/pages/body-proportions/ManualProportions.tsx @@ -125,7 +125,11 @@ function ImportExportButtons() { const onImport = async () => { const file = await fileOpen({ mimeTypes: ['application/json'], + }).catch((err) => { + error(err); + return null; }); + if (!file) return; const text = await file.text(); const config = JSON.parse(text) as SkeletonConfigExport; diff --git a/gui/src/utils/logging.ts b/gui/src/utils/logging.ts index 75cf8c41e..081e78c7d 100644 --- a/gui/src/utils/logging.ts +++ b/gui/src/utils/logging.ts @@ -1,16 +1,16 @@ -import { invoke } from '@tauri-apps/api/core'; +import { invoke, isTauri } from '@tauri-apps/api/core'; export function log(...msgs: any[]) { console.log(...msgs); - invoke('logging', { msg: msgs.join() }); + if (isTauri()) invoke('logging', { msg: msgs.join() }); } export function error(...msgs: any[]) { console.error(...msgs); - invoke('erroring', { msg: msgs.join() }); + if (isTauri()) invoke('erroring', { msg: msgs.join() }); } export function warn(...msgs: any[]) { console.warn(...msgs); - invoke('warning', { msg: msgs.join() }); + if (isTauri()) invoke('warning', { msg: msgs.join() }); }