Fix settings saving

This commit is contained in:
smartfrigde 2022-04-17 20:55:30 +02:00
parent 16531fa922
commit 03e45c272c
3 changed files with 16 additions and 15 deletions

View file

@ -67,15 +67,15 @@
loadSettings(); loadSettings();
document.getElementById("save").addEventListener("click", function () { document.getElementById("save").addEventListener("click", function () {
//function saveSettings(windowStyle: string, channelSetting: string, armcordCSPSetting: boolean, minimizeToTray: boolean, automaticPatches: boolean,modsSetting: string, blurType: string) //function saveSettings(windowStyle: string, channelSetting: string, armcordCSPSetting: boolean, minimizeToTray: boolean, automaticPatches: boolean,modsSetting: string, blurType: string)
settings.save( settings.save({
document.getElementById("theme").value, windowStyle: document.getElementById("theme").value,
document.getElementById("channel").value, channel: document.getElementById("channel").value,
document.getElementById("csp").checked, armcordCSP: document.getElementById("csp").checked,
document.getElementById("tray").checked, minimizeToTray: document.getElementById("tray").checked,
document.getElementById("patches").checked, automaticPatches: document.getElementById("patches").checked,
document.getElementById("mod").value, mods: document.getElementById("mod").value,
"acrylic" blurType: "acrylic"
); });
}); });
</script> </script>
</html> </html>

View file

@ -1,6 +1,6 @@
import * as storage from "electron-json-storage"; import * as storage from "electron-json-storage";
import * as fs from "fs"; import * as fs from "fs";
import {app} from "electron"; import {app, dialog} from "electron";
import path from "path"; import path from "path";
export var firstRun: boolean; export var firstRun: boolean;
@ -21,10 +21,11 @@ export async function sleep(ms: number) {
return new Promise((resolve) => setTimeout(resolve, ms)); return new Promise((resolve) => setTimeout(resolve, ms));
} }
export async function checkIfConfigIsNew() { export async function checkIfConfigIsBroken() {
if (await getConfigUnsafe("automaticPatches") == undefined) { if (await getConfigUnsafe("0") == "d") {
console.log("Outdated config") console.log("Detected a corrupted config")
setup() 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.")
} }
} }

View file

@ -5,7 +5,7 @@
import {BrowserWindow, shell, app, ipcMain, dialog} from "electron"; import {BrowserWindow, shell, app, ipcMain, dialog} from "electron";
import path from "path"; import path from "path";
import {contentPath} from "./main"; import {contentPath} from "./main";
import {checkIfConfigIsNew, firstRun, getConfigUnsafe} from "./utils"; import {checkIfConfigIsBroken, firstRun, getConfigUnsafe} from "./utils";
import {registerIpc} from "./ipc"; import {registerIpc} from "./ipc";
import contextMenu from "electron-context-menu"; import contextMenu from "electron-context-menu";
export let mainWindow: BrowserWindow; export let mainWindow: BrowserWindow;
@ -19,7 +19,7 @@ contextMenu({
}); });
function doAfterDefiningTheWindow() { function doAfterDefiningTheWindow() {
checkIfConfigIsNew(); checkIfConfigIsBroken()
registerIpc(); registerIpc();
mainWindow.webContents.userAgent = 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 "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