brought back db config sync

This commit is contained in:
Jack 2021-04-05 18:33:14 +01:00
parent 0167358a62
commit f76169c76d

View file

@ -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 {