mirror of
https://github.com/Ylianst/MeshCentral.git
synced 2025-02-12 11:01:52 +00:00
fix messenger background notifications #2440
Signed-off-by: si458 <simonsmith5521@gmail.com>
This commit is contained in:
parent
d9262f7c9d
commit
ce4217c346
1 changed files with 6 additions and 6 deletions
|
@ -85,7 +85,6 @@
|
||||||
var remoteUserId = '{{{userid}}}';
|
var remoteUserId = '{{{userid}}}';
|
||||||
var webrtcconfiguration = '{{{webrtcconfig}}}';
|
var webrtcconfiguration = '{{{webrtcconfig}}}';
|
||||||
if (webrtcconfiguration == '') { webrtcconfiguration = null; } else { try { webrtcconfiguration = JSON.parse(decodeURIComponent(webrtcconfiguration)); } catch (ex) { console.log('Invalid WebRTC config: "' + webrtcconfiguration + '".'); webrtcconfiguration = null; } }
|
if (webrtcconfiguration == '') { webrtcconfiguration = null; } else { try { webrtcconfiguration = JSON.parse(decodeURIComponent(webrtcconfiguration)); } catch (ex) { console.log('Invalid WebRTC config: "' + webrtcconfiguration + '".'); webrtcconfiguration = null; } }
|
||||||
var windowFocus = true;
|
|
||||||
var chatTextSession = new Date().toString() + '\r\n';
|
var chatTextSession = new Date().toString() + '\r\n';
|
||||||
var localOutText = false;
|
var localOutText = false;
|
||||||
var remoteOutText = false;
|
var remoteOutText = false;
|
||||||
|
@ -124,10 +123,6 @@
|
||||||
// Setup web notifications
|
// Setup web notifications
|
||||||
try { if (Notification) { QV('notifyButton', Notification.permission != 'granted'); } } catch (ex) { notificationSupport = false; }
|
try { if (Notification) { QV('notifyButton', Notification.permission != 'granted'); } } catch (ex) { notificationSupport = false; }
|
||||||
|
|
||||||
// Track window focus
|
|
||||||
window.addEventListener('focus', function (event) { windowFocus = true; }, false);
|
|
||||||
window.addEventListener('blur', function (event) { windowFocus = false; }, false);
|
|
||||||
|
|
||||||
// Listen to drag & drop events
|
// Listen to drag & drop events
|
||||||
document.addEventListener('dragover', haltEvent, false);
|
document.addEventListener('dragover', haltEvent, false);
|
||||||
document.addEventListener('dragleave', haltEvent, false);
|
document.addEventListener('dragleave', haltEvent, false);
|
||||||
|
@ -237,9 +232,14 @@
|
||||||
// If web notifications are granted, use it.
|
// If web notifications are granted, use it.
|
||||||
if (notificationSupport) {
|
if (notificationSupport) {
|
||||||
if (Notification) { QV('notifyButton', Notification.permission != 'granted'); }
|
if (Notification) { QV('notifyButton', Notification.permission != 'granted'); }
|
||||||
if (Notification && (windowFocus == false) && (Notification.permission == 'granted')) {
|
if (Notification && (document.visibilityState === 'hidden') && (Notification.permission == 'granted')) {
|
||||||
if (notification != null) { notification.close(); notification = null; }
|
if (notification != null) { notification.close(); notification = null; }
|
||||||
notification = new Notification(Q('xtitle').innerHTML.split(' ').join(' '), { body: msg });
|
notification = new Notification(Q('xtitle').innerHTML.split(' ').join(' '), { body: msg });
|
||||||
|
notification.onclick = function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
if (document.visibilityState === 'hidden') window.focus();
|
||||||
|
notification.close();
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue