Browse Source

Improved PUSH-handling in Chrome

Possibly fixes #1458
master
Igor Zhukov 6 years ago
parent
commit
7d408a6dbe
  1. 10
      app/js/lib/push_worker.js

10
app/js/lib/push_worker.js

@ -54,13 +54,13 @@ self.addEventListener('push', function(event) { @@ -54,13 +54,13 @@ self.addEventListener('push', function(event) {
var closePromise = notificationPromise.catch(function () {
console.log('[SW] Closing all notifications on push', hasActiveWindows)
if (userInvisibleIsSupported()) {
if (userInvisibleIsSupported() || hasActiveWindows) {
return closeAllNotifications()
}
var promise = self.registration.showNotification('Telegram').then(function () {
// if (hasActiveWindows) {
// return closeAllNotifications()
// }
if (hasActiveWindows) {
return closeAllNotifications()
}
setTimeout(closeAllNotifications, hasActiveWindows ? 0 : 100)
}).catch(function (error) {
console.error('Show notification error', error)
@ -133,6 +133,8 @@ function fireNotification(obj, settings, lang) { @@ -133,6 +133,8 @@ function fireNotification(obj, settings, lang) {
tag = 'unknown_peer'
}
console.log('[SW] show notify', title, body, icon, obj)
var notificationPromise = self.registration.showNotification(title, {
body: body,
icon: icon,

Loading…
Cancel
Save