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
|
||||
showCachedAlerts();
|
||||
|
||||
// Start notification background worker to check every 1 seconds if notifications are available
|
||||
setInterval(notificationCheck, 1000);
|
||||
// always refresh when the focus returns
|
||||
$(document).focus(function(){
|
||||
startNotificationWatcher();
|
||||
});
|
||||
|
||||
// also run when the focus returns
|
||||
$(document).on('focus', function(e){
|
||||
notificationCheck(force = true);
|
||||
// kill notification watcher if focus is lost -> respect your users cycles
|
||||
$(document).focusout(function(){
|
||||
stopNotificationWatcher();
|
||||
});
|
||||
|
||||
$('#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;
|
||||
/**
|
||||
* 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