Skip to content

Commit

Permalink
fix: settings error on first load
Browse files Browse the repository at this point in the history
  • Loading branch information
dubisdev committed Feb 22, 2023
1 parent 741637b commit d11dc4a
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
2 changes: 1 addition & 1 deletion index.html
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<head>
<meta charset="UTF-8" />
<link rel="icon" href="data:,">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; style-src 'self'">
<meta http-equiv="Content-Security-Policy" content="default-src 'self'; style-src 'self' 'unsafe-inline'">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>RunMath</title>
</head>
Expand Down
9 changes: 5 additions & 4 deletions src/utils/settingsPageLauncher.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -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();
Expand Down

0 comments on commit d11dc4a

Please sign in to comment.