diff --git a/src/js/account.js b/src/js/account.js index fc4e58146..02d615bcb 100644 --- a/src/js/account.js +++ b/src/js/account.js @@ -73,47 +73,48 @@ export function getDataAndInit() { TestLogic.restart(false, true); } else if (DB.getSnapshot().config !== undefined) { //loading db config, keep for now - // let configsDifferent = false; - // Object.keys(config).forEach((key) => { - // if (!configsDifferent) { - // try { - // if (key !== "resultFilters") { - // if (Array.isArray(config[key])) { - // config[key].forEach((arrval, index) => { - // if (arrval != DB.getSnapshot().config[key][index]) { - // configsDifferent = true; - // console.log( - // `.config is different: ${arrval} != ${DB.getSnapshot().config[key][index] - // }` - // ); - // } - // }); - // } else { - // if (config[key] != DB.getSnapshot().config[key]) { - // configsDifferent = true; - // console.log( - // `..config is different ${key}: ${config[key]} != ${DB.getSnapshot().config[key] - // }` - // ); - // } - // } - // } - // } catch (e) { - // console.log(e); - // configsDifferent = true; - // console.log(`...config is different: ${e.message}`); - // } - // } - // }); - // if (configsDifferent) { - // console.log("applying config from db"); - // AccountButton.loading(false); - // config = DB.getSnapshot().config; - // applyConfig(config); - // Settings.update(); - // saveConfigToCookie(true); - // TestLogic.restart(false, true); - // } + let configsDifferent = false; + Object.keys(Config).forEach((key) => { + if (!configsDifferent) { + try { + if (key !== "resultFilters") { + if (Array.isArray(Config[key])) { + Config[key].forEach((arrval, index) => { + if (arrval != DB.getSnapshot().config[key][index]) { + configsDifferent = true; + console.log( + `.config is different: ${arrval} != ${ + DB.getSnapshot().config[key][index] + }` + ); + } + }); + } else { + if (Config[key] != DB.getSnapshot().config[key]) { + configsDifferent = true; + console.log( + `..config is different ${key}: ${Config[key]} != ${ + DB.getSnapshot().config[key] + }` + ); + } + } + } + } catch (e) { + console.log(e); + configsDifferent = true; + console.log(`...config is different: ${e.message}`); + } + } + }); + if (configsDifferent) { + console.log("applying config from db"); + AccountButton.loading(false); + UpdateConfig.apply(DB.getSnapshot().config); + Settings.update(); + UpdateConfig.saveToCookie(true); + TestLogic.restart(false, true); + } } UpdateConfig.setDbConfigLoaded(true); } else {