mirror of
https://github.com/inventree/InvenTree
synced 2024-08-30 18:33:04 +00:00
check if notifications are there regularly
This commit is contained in:
parent
866674497a
commit
e01f2e202e
@ -1,6 +1,7 @@
|
|||||||
/* globals
|
/* globals
|
||||||
ClipboardJS,
|
ClipboardJS,
|
||||||
inventreeFormDataUpload,
|
inventreeFormDataUpload,
|
||||||
|
inventreeGet,
|
||||||
launchModalForm,
|
launchModalForm,
|
||||||
user_settings,
|
user_settings,
|
||||||
*/
|
*/
|
||||||
@ -216,6 +217,39 @@ function inventreeDocReady() {
|
|||||||
|
|
||||||
// Display any cached alert messages
|
// Display any cached alert messages
|
||||||
showCachedAlerts();
|
showCachedAlerts();
|
||||||
|
|
||||||
|
// Start notification background worker to check every 5 seconds if notifications are available
|
||||||
|
var notificationRunner = setInterval(notificationCheck, 5000);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The notification checker is initiated when the doc is loaded. It checks if there are unread notifications
|
||||||
|
* if unread messages exist the alert flag is raised by making it visible
|
||||||
|
**/
|
||||||
|
var current_alert_state = false;
|
||||||
|
function notificationCheck() {
|
||||||
|
inventreeGet(
|
||||||
|
'/api/notifications/',
|
||||||
|
{
|
||||||
|
read: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
success: function(response) {
|
||||||
|
if (response.length == 0) {
|
||||||
|
if (current_alert_state == true){
|
||||||
|
$("#notification-alert").addClass("d-none");
|
||||||
|
current_alert_state = false;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (current_alert_state == false){
|
||||||
|
$("#notification-alert").removeClass("d-none");
|
||||||
|
current_alert_state = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function isFileTransfer(transfer) {
|
function isFileTransfer(transfer) {
|
||||||
|
Loading…
Reference in New Issue
Block a user