From 519b5b701258c2ab488ed6c824c8fad4f7e1f1cb Mon Sep 17 00:00:00 2001 From: Matthias Date: Sat, 27 Nov 2021 23:14:38 +0100 Subject: [PATCH] fix focusing --- InvenTree/InvenTree/static/script/inventree/inventree.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/InvenTree/InvenTree/static/script/inventree/inventree.js b/InvenTree/InvenTree/static/script/inventree/inventree.js index 5d95d0b618..a7e1dc31ae 100644 --- a/InvenTree/InvenTree/static/script/inventree/inventree.js +++ b/InvenTree/InvenTree/static/script/inventree/inventree.js @@ -220,6 +220,11 @@ function inventreeDocReady() { // Start notification background worker to check every 5 seconds if notifications are available var notificationRunner = setInterval(notificationCheck, 5000); + + // also run when the focus returns + $(document).on('focus', function(e){ + notificationCheck(); + }); } @@ -229,6 +234,8 @@ function inventreeDocReady() { **/ var current_alert_state = false; function notificationCheck() { + // only refresh state if in focus + if (document.hasFocus()) { inventreeGet( '/api/notifications/', { @@ -250,6 +257,7 @@ function notificationCheck() { } } ); + } } function isFileTransfer(transfer) {