diff --git a/src/main.ts b/src/main.ts index e48d942..b7662eb 100644 --- a/src/main.ts +++ b/src/main.ts @@ -6,6 +6,7 @@ import { checkForDataFolder, checkIfConfigExists, firstRun, + checkIfConfigIsBroken, getConfig, getConfigSync, injectElectronFlags, @@ -70,7 +71,7 @@ if (!app.requestSingleInstanceLock() && getConfigSync("multiInstance") == (false } // work around chrome 66 disabling autoplay by default app.commandLine.appendSwitch("autoplay-policy", "no-user-gesture-required"); - + checkIfConfigIsBroken(); // WinRetrieveSuggestionsOnlyOnDemand: Work around electron 13 bug w/ async spellchecking on Windows. // HardwareMediaKeyHandling,MediaSessionService: Prevent Discord from registering as a media service. app.commandLine.appendSwitch( diff --git a/src/utils.ts b/src/utils.ts index 0bf6261..0cc191d 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -26,7 +26,12 @@ export async function sleep(ms: number): Promise { } export async function checkIfConfigIsBroken(): Promise { - if ((await getConfig("0")) == "d") { + try { + let rawdata = fs.readFileSync(getConfigLocation(), "utf-8"); + JSON.parse(rawdata); + console.log("Config is fine"); + } catch (e) { + console.error(e); console.log("Detected a corrupted config"); setup(); dialog.showErrorBox( diff --git a/src/window.ts b/src/window.ts index 25633c5..217b2e1 100644 --- a/src/window.ts +++ b/src/window.ts @@ -5,7 +5,6 @@ import {BrowserWindow, MessageBoxOptions, app, dialog, nativeImage, shell} from "electron"; import path from "path"; import { - checkIfConfigIsBroken, contentPath, firstRun, getConfig, @@ -68,7 +67,6 @@ async function doAfterDefiningTheWindow(): Promise { } } let ignoreProtocolWarning = await getConfig("ignoreProtocolWarning"); - await checkIfConfigIsBroken(); registerIpc(); if (await getConfig("mobileMode")) { mainWindow.webContents.userAgent =