From d11dc4a61744d5f6e9fe0c7b60947a7c260073c0 Mon Sep 17 00:00:00 2001 From: dubisdev Date: Wed, 22 Feb 2023 19:26:32 +0100 Subject: [PATCH] fix: settings error on first load --- index.html | 2 +- src/utils/settingsPageLauncher.ts | 9 +++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/index.html b/index.html index a424ecc..af63afe 100644 --- a/index.html +++ b/index.html @@ -4,7 +4,7 @@ - + RunMath diff --git a/src/utils/settingsPageLauncher.ts b/src/utils/settingsPageLauncher.ts index bcd371a..507fc45 100644 --- a/src/utils/settingsPageLauncher.ts +++ b/src/utils/settingsPageLauncher.ts @@ -1,8 +1,9 @@ import { WebviewWindow } from "@tauri-apps/api/window"; -import { TauriEvent } from "@tauri-apps/api/event"; + +const SETTINGS_PAGE_LABEL = "settings-page"; export const createSettingsPage = () => { - const webview = new WebviewWindow("settings-page", { + const webview = new WebviewWindow(SETTINGS_PAGE_LABEL, { minWidth: 400, minHeight: 500, maxWidth: 800, @@ -12,12 +13,12 @@ export const createSettingsPage = () => { url: "settings.html", }); - webview.once(TauriEvent.WINDOW_CREATED, () => { + webview.once("tauri://created", () => { webview.show(); }); webview.once<"tauri://error">("tauri://error", async (e) => { - if (e.payload.includes("`settings-page` already exists")) { + if (e.payload.includes(` \`${SETTINGS_PAGE_LABEL}\` already exists`)) { await webview.unminimize(); await webview.show(); await webview.setFocus();