diff options
author | rstular <rok@stular.eu> | 2020-06-18 10:30:51 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-18 10:30:51 +0200 |
commit | 355d89863fc721f4024c516d2863a16d20540fdf (patch) | |
tree | d09edec73d65f81adfdb1139a46713f6c50ebe6a /assets/js/setup-storage.js | |
parent | Merge pull request #23 from beziapp/dev (diff) | |
parent | fixed help screens and notices for make generate != make install (diff) | |
download | beziapp-355d89863fc721f4024c516d2863a16d20540fdf.tar beziapp-355d89863fc721f4024c516d2863a16d20540fdf.tar.gz beziapp-355d89863fc721f4024c516d2863a16d20540fdf.tar.bz2 beziapp-355d89863fc721f4024c516d2863a16d20540fdf.tar.lz beziapp-355d89863fc721f4024c516d2863a16d20540fdf.tar.xz beziapp-355d89863fc721f4024c516d2863a16d20540fdf.tar.zst beziapp-355d89863fc721f4024c516d2863a16d20540fdf.zip |
Diffstat (limited to 'assets/js/setup-storage.js')
-rw-r--r-- | assets/js/setup-storage.js | 77 |
1 files changed, 38 insertions, 39 deletions
diff --git a/assets/js/setup-storage.js b/assets/js/setup-storage.js index c862d5f..b29c959 100644 --- a/assets/js/setup-storage.js +++ b/assets/js/setup-storage.js @@ -1,44 +1,43 @@ async function setupStorage(force = false) { - let logged_in; - promises_check_if_already_installed = [ - localforage.getItem("logged_in").then( function(val) { - console.log("[setupStorage] logged in status: " + val); - logged_in = val; - }) - ]; - await Promise.all(promises_check_if_already_installed); + let logged_in; + promises_check_if_already_installed = [ + localforage.getItem("logged_in").then(function (val) { + console.log("[setupStorage] logged in status: " + val); + logged_in = val; + }) + ]; + await Promise.all(promises_check_if_already_installed); - let promises_update = [ - localforage.setItem("profile", {}), - localforage.setItem("timetable", []), - localforage.setItem("teachers", []), - localforage.setItem("gradings", []), - localforage.setItem("grades", []), - localforage.setItem("absences", {}), - localforage.setItem("messages", [[], [], []]), // see messages.js:129, commit 8eb9ca9caca30fbbe023243657535ab4088be377 - localforage.setItem("directory", {}), //\\ well I could remember my own code but I didn't. - localforage.setItem("meals", {}), - localforage.setItem("chosenLang", "en"), - localforage.setItem("theme", "light"), - localforage.setItem("errorReporting", "on"), - localforage.setItem("triggerWarningAccepted", false) - ]; + let promises_update = [ + localforage.setItem("profile", {}), + localforage.setItem("timetable", []), + localforage.setItem("teachers", []), + localforage.setItem("gradings", []), + localforage.setItem("grades", []), + localforage.setItem("absences", {}), + localforage.setItem("messages", [[], [], []]), // see messages.js:129, commit 8eb9ca9caca30fbbe023243657535ab4088be377 + localforage.setItem("directory", {}), //\\ well I could remember my own code but I didn't. + localforage.setItem("meals", {}), + localforage.setItem("chosenLang", "en"), + localforage.setItem("theme", "light"), + localforage.setItem("errorReporting", "on"), + localforage.setItem("lastUpdate", 0), + localforage.setItem("triggerWarningAccepted", false) + ]; - if (logged_in && force == false) { // torej, če je že bila prijava narejena, ne posodobi backwards-compatible vrednosti (username, password,...) - await Promise.all(promises_update); - console.log("[setupStorage] user logged in: only updated"); - } else { + if (logged_in && force == false) { // torej, če je že bila prijava narejena, ne posodobi backwards-compatible vrednosti (username, password,...) + await Promise.all(promises_update); + console.log("[setupStorage] user logged in: only updated"); + } else { - let promises_first_install = [ - localforage.setItem("logged_in", false), - localforage.setItem("username", ""), - localforage.setItem("password", ""), - localforage.setItem("chosenLang", "en"), - localforage.setItem("theme", "light"), - localforage.setItem("triggerWarningAccepted", false) - ]; - await localforage.clear(); - await Promise.all(promises_first_install); - console.log("[setupStorage] user not logged in: set up whole database"); - } + let promises_first_install = [ + localforage.setItem("logged_in", false), + localforage.setItem("username", ""), + localforage.setItem("password", ""), + ]; + await localforage.clear(); + await Promise.all(promises_first_install); + await Promise.all(promises_update); + console.log("[setupStorage] user not logged in: set up whole database"); + } } |