From 3cf29154aa779b99e62dda39a43af8376507df12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Tue, 6 Feb 2024 20:10:06 +0100 Subject: [PATCH] Fix async --- assets/script.js | 35 ++++++++++++++++++----------------- 1 file changed, 18 insertions(+), 17 deletions(-) diff --git a/assets/script.js b/assets/script.js index b435690..a888a45 100644 --- a/assets/script.js +++ b/assets/script.js @@ -6,7 +6,7 @@ toggleButton.addEventListener('click', () => { }) -let UserInfo; +var UserInfo; function handleResponse(data, successMessage, failureMessage) { const statusMessageContainer = document.getElementById("statusMessageContainer"); @@ -325,11 +325,11 @@ function getUserInfo() { action: "get_user_info", }; - const result = doAction('/account', data, "User info retrieved Successfully!", "User info retrieval failed.", true); - - if (result && result.Status === "Success") { - UserInfo = result.UserInfo; - } + doAction('/account', data, "User info retrieved Successfully!", "User info retrieval failed.", true) .then((result) => { + if (result && result.Status === "Success") { + UserInfo = result.UserInfo; + } + }); } //User settings end @@ -344,10 +344,10 @@ function addActivationCodes() { count: count, }; - const result = doAction('/account', data, "Activation codes added Successfully!", "Activation codes addition failed."); - - displayList(result.ActivationCodes, "codeListTable", deleteActivationCode); - umami.track("addActivationCodes"); + doAction('/account', data, "Activation codes added Successfully!", "Activation codes addition failed.").then((result) => { + displayList(result.ActivationCodes, "codeListTable", deleteActivationCode); + umami.track("addActivationCodes"); + }); } function listUsers() { @@ -355,11 +355,12 @@ function listUsers() { action: "list_users", }; - const result = doAction('/account', data, "User list retrieved Successfully!", "User list retrieval failed."); + doAction('/account', data, "User list retrieved Successfully!", "User list retrieval failed.").then((result) => { - if (result && result.Status === "Success") { - displayList(result.Users, "userListTable", deleteUser); - } + if (result && result.Status === "Success") { + displayList(result.Users, "userListTable", deleteUser); + } + }); } function listActivationCodes() { @@ -367,9 +368,9 @@ function listActivationCodes() { action: "list_activation_codes", }; - const result = doAction('/account', data, "Activation code list retrieved Successfully!", "Activation code list retrieval failed."); - - displayList(result.ActivationCodes, "codeListTable", deleteActivationCode); + doAction('/account', data, "Activation code list retrieved Successfully!", "Activation code list retrieval failed.").then((result) => { + displayList(result.ActivationCodes, "codeListTable", deleteActivationCode); + }); } function deleteUser(userId) {