From ba7a27fe6e77cc0571ba2a6a08d2a08ca96e0a2e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Niedzielski?= Date: Fri, 24 Mar 2023 12:15:31 +0100 Subject: [PATCH] IBX-5369: Fixed admin notifications request being queued too often (#740) Co-authored-by: tischsoic --- .../public/js/scripts/admin.notifications.modal.js | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/bundle/Resources/public/js/scripts/admin.notifications.modal.js b/src/bundle/Resources/public/js/scripts/admin.notifications.modal.js index 03d9dea237..edf17b0bf6 100644 --- a/src/bundle/Resources/public/js/scripts/admin.notifications.modal.js +++ b/src/bundle/Resources/public/js/scripts/admin.notifications.modal.js @@ -58,7 +58,7 @@ }, }); - fetch(request) + return fetch(request) .then(getJsonFromResponse) .then((notificationsInfo) => { setPendingNotificationCount(notificationsInfo); @@ -169,6 +169,11 @@ modal.querySelectorAll(SELECTOR_MODAL_RESULTS).forEach((link) => link.addEventListener('click', handleModalResultsClick, false)); - getNotificationsStatus(); - global.setInterval(getNotificationsStatus, INTERVAL); + const getNotificationsStatusLoop = () => { + getNotificationsStatus().finally(() => { + global.setTimeout(getNotificationsStatusLoop, INTERVAL); + }); + }; + + getNotificationsStatusLoop(); })(window, window.document, window.ibexa, window.Translator);