diff --git a/public/js/account.js b/public/js/account.js index 74f530343..fac94d529 100644 --- a/public/js/account.js +++ b/public/js/account.js @@ -223,73 +223,78 @@ firebase.auth().onAuthStateChanged(function (user) { } updateAccountLoginButton(); accountIconLoading(true); - db_getUserSnapshot().then((e) => { - if (!configChangedBeforeDb) { - if (cookieConfig === null) { - accountIconLoading(false); - applyConfig(dbSnapshot.config); - // showNotification('Applying db config',3000); - updateSettingsPage(); - saveConfigToCookie(true); - } else if (dbSnapshot.config !== undefined) { - 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 != dbSnapshot.config[key][index]) - configsDifferent = true; - }); - } else { - if (config[key] != dbSnapshot.config[key]) - configsDifferent = true; - } - } - } catch (e) { - console.log(e); - configsDifferent = true; - } - } - }); - if (configsDifferent) { + db_getUserSnapshot() + .then((e) => { + if (!configChangedBeforeDb) { + if (cookieConfig === null) { accountIconLoading(false); applyConfig(dbSnapshot.config); + // showNotification('Applying db config',3000); updateSettingsPage(); saveConfigToCookie(true); + } else if (dbSnapshot.config !== undefined) { + 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 != dbSnapshot.config[key][index]) + configsDifferent = true; + }); + } else { + if (config[key] != dbSnapshot.config[key]) + configsDifferent = true; + } + } + } catch (e) { + console.log(e); + configsDifferent = true; + } + } + }); + if (configsDifferent) { + accountIconLoading(false); + applyConfig(dbSnapshot.config); + updateSettingsPage(); + saveConfigToCookie(true); + } + } + dbConfigLoaded = true; + } else { + accountIconLoading(false); + } + if ( + config.resultFilters === undefined || + config.resultFilters === null || + config.resultFilters.difficulty === undefined + ) { + if ( + dbSnapshot.config.resultFilters == null || + dbSnapshot.config.resultFilters.difficulty === undefined + ) { + config.resultFilters = defaultAccountFilters; + } else { + config.resultFilters = dbSnapshot.config.resultFilters; } } - dbConfigLoaded = true; - } else { - accountIconLoading(false); - } - if ( - config.resultFilters === undefined || - config.resultFilters === null || - config.resultFilters.difficulty === undefined - ) { - if ( - dbSnapshot.config.resultFilters == null || - dbSnapshot.config.resultFilters.difficulty === undefined - ) { - config.resultFilters = defaultAccountFilters; - } else { - config.resultFilters = dbSnapshot.config.resultFilters; + if ($(".pageLogin").hasClass("active")) { + changePage("account"); } - } - if ($(".pageLogin").hasClass("active")) { - changePage("account"); - } - refreshThemeButtons(); - accountIconLoading(false); - updateFilterTags(); - updateCommandsTagsList(); - loadActiveTagsFromCookie(); - updateResultEditTagsPanelButtons(); - refreshTagsSettingsSection(); - updateDiscordSettingsSection(); - }); + refreshThemeButtons(); + accountIconLoading(false); + updateFilterTags(); + updateCommandsTagsList(); + loadActiveTagsFromCookie(); + updateResultEditTagsPanelButtons(); + refreshTagsSettingsSection(); + updateDiscordSettingsSection(); + }) + .catch((e) => { + accountIconLoading(false); + showNotification("Error donwloading user data: " + e, 5000); + }); var displayName = user.displayName; var email = user.email; var emailVerified = user.emailVerified;