wait for fetch to finish

This commit is contained in:
Bruno Rybársky 2024-02-05 23:07:09 +01:00
parent f33837f023
commit 52e30c1e99

@ -125,10 +125,12 @@ function navigateTo(site, page){
data.append("action", "getPage"); data.append("action", "getPage");
data.append("site", site); data.append("site", site);
data.append("page", page); data.append("page", page);
doPageAction(data); doPageAction(data).then((value) => {
localStorage.setItem("currentSite", site); localStorage.setItem("currentSite", site);
localStorage.setItem("currentPage", page); localStorage.setItem("currentPage", page);
onPageLoad(); onPageLoad();
// Expected output: "Success!"
});
} }
function softReload(){ function softReload(){
@ -179,18 +181,13 @@ document.addEventListener('DOMContentLoaded', initAjax);
function onPageLoad(){ function onPageLoad(){
let currentSite = localStorage.getItem("currentSite"); let currentSite = localStorage.getItem("currentSite");
let currentPage = localStorage.getItem("currentPage"); let currentPage = localStorage.getItem("currentPage");
console.log("We arrived on: " + currentSite + ":" + currentPage + ".");
if(currentSite === "home" && currentPage === "settings"){ if(currentSite === "home" && currentPage === "settings"){
if(document.getElementById("user-settings")){ if(document.getElementById("user-settings")){
getUserInfo(); getUserInfo();
console.log("Running user info");
} }
}
if(currentSite === "home" && currentPage === "settings"){
if(document.getElementById("admin-settings")){ if(document.getElementById("admin-settings")){
listActivationCodes(); listActivationCodes();
listUsers(); listUsers();
console.log("Running admin info");
} }
} }
} }