diff options
author | rstular <rok@stular.eu> | 2020-05-16 23:20:42 +0200 |
---|---|---|
committer | rstular <rok@stular.eu> | 2020-05-16 23:20:46 +0200 |
commit | ad675cbe9738577b236c5a682e4629c562ee4a76 (patch) | |
tree | 91e065c79686654a9b78f3872ea54061eb8ae5a8 /js/setup-storage.js | |
parent | Bug fix - absences time frame calculations (diff) | |
download | beziapp-ad675cbe9738577b236c5a682e4629c562ee4a76.tar beziapp-ad675cbe9738577b236c5a682e4629c562ee4a76.tar.gz beziapp-ad675cbe9738577b236c5a682e4629c562ee4a76.tar.bz2 beziapp-ad675cbe9738577b236c5a682e4629c562ee4a76.tar.lz beziapp-ad675cbe9738577b236c5a682e4629c562ee4a76.tar.xz beziapp-ad675cbe9738577b236c5a682e4629c562ee4a76.tar.zst beziapp-ad675cbe9738577b236c5a682e4629c562ee4a76.zip |
Diffstat (limited to '')
-rw-r--r-- | js/setup-storage.js | 68 |
1 files changed, 35 insertions, 33 deletions
diff --git a/js/setup-storage.js b/js/setup-storage.js index a3b7cdd..a37fc8f 100644 --- a/js/setup-storage.js +++ b/js/setup-storage.js @@ -1,35 +1,37 @@ async function setupStorage(force = false) { - let logged_in, setup_promises; - 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", { "0": [], "1": [], "2": []}), // see messages.js:129, commit 8eb9ca9caca30fbbe023243657535ab4088be377 - localforage.setItem("directory", {}), //\\ well I could remember my own code but I didn't. - localforage.setItem("meals", {}) - ]; - 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") - ]; - await localforage.clear(); - await Promise.all(promises_first_install); - console.log("[setupStorage] user not logged in: set up whole database"); - } + 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", { "0": [], "1": [], "2": []}), // see messages.js:129, commit 8eb9ca9caca30fbbe023243657535ab4088be377 + localforage.setItem("directory", {}), //\\ well I could remember my own code but I didn't. + localforage.setItem("meals", {}) + ]; + + 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") + ]; + await localforage.clear(); + await Promise.all(promises_first_install); + console.log("[setupStorage] user not logged in: set up whole database"); + } } |