summaryrefslogtreecommitdiffstats
path: root/dist/js/setup-storage.js
diff options
context:
space:
mode:
authorsijanec <sijanecantonluka@gmail.com>2020-09-26 21:42:10 +0200
committersijanec <sijanecantonluka@gmail.com>2020-09-26 21:42:10 +0200
commit3a3246dfecab404df90513989bf84a270e17d1f1 (patch)
tree629eb2d4f82d561fa709150742bb64c0bef54759 /dist/js/setup-storage.js
parentunset tracking vars are now not reported to the spyware server (diff)
downloadbeziapp-3a3246dfecab404df90513989bf84a270e17d1f1.tar
beziapp-3a3246dfecab404df90513989bf84a270e17d1f1.tar.gz
beziapp-3a3246dfecab404df90513989bf84a270e17d1f1.tar.bz2
beziapp-3a3246dfecab404df90513989bf84a270e17d1f1.tar.lz
beziapp-3a3246dfecab404df90513989bf84a270e17d1f1.tar.xz
beziapp-3a3246dfecab404df90513989bf84a270e17d1f1.tar.zst
beziapp-3a3246dfecab404df90513989bf84a270e17d1f1.zip
Diffstat (limited to 'dist/js/setup-storage.js')
-rwxr-xr-xdist/js/setup-storage.js43
1 files changed, 42 insertions, 1 deletions
diff --git a/dist/js/setup-storage.js b/dist/js/setup-storage.js
index be05650..b29c959 100755
--- a/dist/js/setup-storage.js
+++ b/dist/js/setup-storage.js
@@ -1,2 +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);
-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 promises_update=[localforage.setItem("profile",{}),localforage.setItem("timetable",[]),localforage.setItem("teachers",[]),localforage.setItem("gradings",[]),localforage.setItem("grades",[]),localforage.setItem("absences",{}),localforage.setItem("messages",[[],[],[]]),localforage.setItem("directory",{}),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){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",""),];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");}} \ No newline at end of file
+ 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 {
+
+ 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");
+ }
+}