mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
reduce needed cyle when idleing
This commit is contained in:
parent
cc9107d72a
commit
ec7ef6ef1e
@ -218,12 +218,14 @@ function inventreeDocReady() {
|
|||||||
// Display any cached alert messages
|
// Display any cached alert messages
|
||||||
showCachedAlerts();
|
showCachedAlerts();
|
||||||
|
|
||||||
// Start notification background worker to check every 1 seconds if notifications are available
|
// always refresh when the focus returns
|
||||||
setInterval(notificationCheck, 1000);
|
$(document).focus(function(){
|
||||||
|
startNotificationWatcher();
|
||||||
|
});
|
||||||
|
|
||||||
// also run when the focus returns
|
// kill notification watcher if focus is lost -> respect your users cycles
|
||||||
$(document).on('focus', function(e){
|
$(document).focusout(function(){
|
||||||
notificationCheck(force = true);
|
stopNotificationWatcher();
|
||||||
});
|
});
|
||||||
|
|
||||||
$('#offcanvasRight').on('show.bs.offcanvas', openNotificationPanel) // listener for opening the notification panel
|
$('#offcanvasRight').on('show.bs.offcanvas', openNotificationPanel) // listener for opening the notification panel
|
||||||
|
@ -119,6 +119,23 @@ function showMessage(message, options={}) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var notificationWatcher = null; // reference for the notificationWatcher
|
||||||
|
/**
|
||||||
|
* start the regular notification checks
|
||||||
|
**/
|
||||||
|
function startNotificationWatcher() {
|
||||||
|
notificationCheck(force=true);
|
||||||
|
notificationWatcher = setInterval(notificationCheck, 1000);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* stop the regular notification checks
|
||||||
|
**/
|
||||||
|
function stopNotificationWatcher() {
|
||||||
|
clearInterval(notificationWatcher);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
var notificationUpdateTic = 0;
|
var notificationUpdateTic = 0;
|
||||||
/**
|
/**
|
||||||
* The notification checker is initiated when the document is loaded. It checks if there are unread notifications
|
* The notification checker is initiated when the document is loaded. It checks if there are unread notifications
|
||||||
|
Loading…
Reference in New Issue
Block a user