From 03e45c272cfb231c5c2fbd8da4a768bf179d0e9a Mon Sep 17 00:00:00 2001 From: smartfrigde <37928912+smartfrigde@users.noreply.github.com> Date: Sun, 17 Apr 2022 20:55:30 +0200 Subject: [PATCH] Fix settings saving --- src/settings/settings.html | 18 +++++++++--------- src/utils.ts | 9 +++++---- src/window.ts | 4 ++-- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/src/settings/settings.html b/src/settings/settings.html index 5c2a653..2b8151f 100644 --- a/src/settings/settings.html +++ b/src/settings/settings.html @@ -67,15 +67,15 @@ loadSettings(); document.getElementById("save").addEventListener("click", function () { //function saveSettings(windowStyle: string, channelSetting: string, armcordCSPSetting: boolean, minimizeToTray: boolean, automaticPatches: boolean,modsSetting: string, blurType: string) - settings.save( - document.getElementById("theme").value, - document.getElementById("channel").value, - document.getElementById("csp").checked, - document.getElementById("tray").checked, - document.getElementById("patches").checked, - document.getElementById("mod").value, - "acrylic" - ); + settings.save({ + windowStyle: document.getElementById("theme").value, + channel: document.getElementById("channel").value, + armcordCSP: document.getElementById("csp").checked, + minimizeToTray: document.getElementById("tray").checked, + automaticPatches: document.getElementById("patches").checked, + mods: document.getElementById("mod").value, + blurType: "acrylic" + }); }); diff --git a/src/utils.ts b/src/utils.ts index 4dbb84e..2e43556 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,6 +1,6 @@ import * as storage from "electron-json-storage"; import * as fs from "fs"; -import {app} from "electron"; +import {app, dialog} from "electron"; import path from "path"; export var firstRun: boolean; @@ -21,10 +21,11 @@ export async function sleep(ms: number) { return new Promise((resolve) => setTimeout(resolve, ms)); } -export async function checkIfConfigIsNew() { - if (await getConfigUnsafe("automaticPatches") == undefined) { - console.log("Outdated config") +export async function checkIfConfigIsBroken() { + if (await getConfigUnsafe("0") == "d") { + console.log("Detected a corrupted config") setup() + dialog.showErrorBox("Oops, something went wrong.", "ArmCord has detected that your configuration file is corrupted, please restart the app and set your settings again. If this issue persists, report it on the support server/Github issues.") } } diff --git a/src/window.ts b/src/window.ts index b151d73..ba3e550 100644 --- a/src/window.ts +++ b/src/window.ts @@ -5,7 +5,7 @@ import {BrowserWindow, shell, app, ipcMain, dialog} from "electron"; import path from "path"; import {contentPath} from "./main"; -import {checkIfConfigIsNew, firstRun, getConfigUnsafe} from "./utils"; +import {checkIfConfigIsBroken, firstRun, getConfigUnsafe} from "./utils"; import {registerIpc} from "./ipc"; import contextMenu from "electron-context-menu"; export let mainWindow: BrowserWindow; @@ -19,7 +19,7 @@ contextMenu({ }); function doAfterDefiningTheWindow() { - checkIfConfigIsNew(); + checkIfConfigIsBroken() registerIpc(); mainWindow.webContents.userAgent = "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/98.0.4758.102 Safari/537.36"; //fake useragent for screenshare to work