fix config loading

This commit is contained in:
Anton Bracke 2022-02-22 20:24:09 +01:00
parent 445bcaf130
commit 44a9e2aeb0
No known key found for this signature in database
GPG Key ID: B1222603899C6B25
2 changed files with 9 additions and 8 deletions

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`); //
} catch (e) { // await fetch(`${server.url}/iframe_api.js`);
console.error(e); // } catch (e) {
return new Error("Invalid server url"); // console.error(e);
} // return new Error("Invalid server url");
// }
const newServer = { const newServer = {
...server, ...server,

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;