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

Loading…
Cancel
Save