fix focusing

This commit is contained in:
Matthias 2021-11-27 23:14:38 +01:00
parent bb1c01635e
commit 519b5b7012
No known key found for this signature in database
GPG Key ID: F50EF5741D33E076

View File

@ -220,6 +220,11 @@ function inventreeDocReady() {
// Start notification background worker to check every 5 seconds if notifications are available // Start notification background worker to check every 5 seconds if notifications are available
var notificationRunner = setInterval(notificationCheck, 5000); 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; var current_alert_state = false;
function notificationCheck() { function notificationCheck() {
// only refresh state if in focus
if (document.hasFocus()) {
inventreeGet( inventreeGet(
'/api/notifications/', '/api/notifications/',
{ {
@ -250,6 +257,7 @@ function notificationCheck() {
} }
} }
); );
}
} }
function isFileTransfer(transfer) { function isFileTransfer(transfer) {