From d2d23d151467dc05c2e91b1a6e748322209dd29b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bruno=20Ryb=C3=A1rsky?= Date: Thu, 25 Apr 2024 22:45:07 +0200 Subject: [PATCH] MEME --- assets/script.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/assets/script.js b/assets/script.js index f5482fd..fce9d3a 100644 --- a/assets/script.js +++ b/assets/script.js @@ -12,6 +12,16 @@ function isLoggedIn() { return UserInfo.Email && 0 < UserInfo.Email.length; } +function until(conditionFunction) { + + const poll = resolve => { + if(conditionFunction()) resolve(); + else setTimeout(_ => poll(resolve), 400); + } + + return new Promise(poll); +} + async function handleResponse(data, successMessage, failureMessage) { "use strict"; const statusMessageContainer = document.getElementById("statusMessageContainer"); @@ -594,7 +604,7 @@ async function getFileList() { } }; xhr.send(formData); - while (tmp === undefined); + until(_ => (tmp !== undefined)); return tmp; }