This commit is contained in:
smartfrigde 2023-09-25 13:15:49 +02:00
parent 9ddf304663
commit b1f876de7c
3 changed files with 8 additions and 4 deletions

View file

@ -6,6 +6,7 @@ import {
checkForDataFolder, checkForDataFolder,
checkIfConfigExists, checkIfConfigExists,
firstRun, firstRun,
checkIfConfigIsBroken,
getConfig, getConfig,
getConfigSync, getConfigSync,
injectElectronFlags, injectElectronFlags,
@ -70,7 +71,7 @@ if (!app.requestSingleInstanceLock() && getConfigSync("multiInstance") == (false
} }
// work around chrome 66 disabling autoplay by default // work around chrome 66 disabling autoplay by default
app.commandLine.appendSwitch("autoplay-policy", "no-user-gesture-required"); app.commandLine.appendSwitch("autoplay-policy", "no-user-gesture-required");
checkIfConfigIsBroken();
// WinRetrieveSuggestionsOnlyOnDemand: Work around electron 13 bug w/ async spellchecking on Windows. // WinRetrieveSuggestionsOnlyOnDemand: Work around electron 13 bug w/ async spellchecking on Windows.
// HardwareMediaKeyHandling,MediaSessionService: Prevent Discord from registering as a media service. // HardwareMediaKeyHandling,MediaSessionService: Prevent Discord from registering as a media service.
app.commandLine.appendSwitch( app.commandLine.appendSwitch(

View file

@ -26,7 +26,12 @@ export async function sleep(ms: number): Promise<void> {
} }
export async function checkIfConfigIsBroken(): Promise<void> { export async function checkIfConfigIsBroken(): Promise<void> {
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"); console.log("Detected a corrupted config");
setup(); setup();
dialog.showErrorBox( dialog.showErrorBox(

View file

@ -5,7 +5,6 @@
import {BrowserWindow, MessageBoxOptions, app, dialog, nativeImage, shell} from "electron"; import {BrowserWindow, MessageBoxOptions, app, dialog, nativeImage, shell} from "electron";
import path from "path"; import path from "path";
import { import {
checkIfConfigIsBroken,
contentPath, contentPath,
firstRun, firstRun,
getConfig, getConfig,
@ -68,7 +67,6 @@ async function doAfterDefiningTheWindow(): Promise<void> {
} }
} }
let ignoreProtocolWarning = await getConfig("ignoreProtocolWarning"); let ignoreProtocolWarning = await getConfig("ignoreProtocolWarning");
await checkIfConfigIsBroken();
registerIpc(); registerIpc();
if (await getConfig("mobileMode")) { if (await getConfig("mobileMode")) {
mainWindow.webContents.userAgent = mainWindow.webContents.userAgent =