fix config loading

This commit is contained in:
Anton Bracke
2022-02-22 20:24:09 +01:00
parent 445bcaf130
commit 44a9e2aeb0
2 changed files with 9 additions and 8 deletions
+6 -5
View File
@@ -58,13 +58,14 @@ export default () => {
ipcMain.handle("local-app:addServer", (event, server: Omit<Server, "_id">) => { ipcMain.handle("local-app:addServer", (event, server: Omit<Server, "_id">) => {
const servers = settings.get("servers") || []; const servers = settings.get("servers") || [];
try {
// TODO: add proper test to see if server url is valid and points to a real WA server // TODO: add proper test to see if server url is valid and points to a real WA server
// try {
//
// await fetch(`${server.url}/iframe_api.js`); // await fetch(`${server.url}/iframe_api.js`);
} catch (e) { // } catch (e) {
console.error(e); // console.error(e);
return new Error("Invalid server url"); // return new Error("Invalid server url");
} // }
const newServer = { const newServer = {
...server, ...server,
+1 -1
View File
@@ -29,7 +29,7 @@ const defaultSettings: SettingsData = {
async function init() { async function init() {
let _settings = await Settings.get(); let _settings = await Settings.get();
if (_settings !== undefined) { if (Object.keys(_settings).length === 0) {
_settings = defaultSettings; _settings = defaultSettings;
} }
settings = _settings as SettingsData; settings = _settings as SettingsData;