mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2025-02-06 13:55:19 +08:00
brought back db config sync
This commit is contained in:
parent
0167358a62
commit
f76169c76d
1 changed files with 42 additions and 41 deletions
|
@ -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 {
|
||||
|
|
Loading…
Reference in a new issue