From 7d408a6dbe1ab334874a22b44211f9262af898ea Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Fri, 29 Dec 2017 15:44:32 +0400 Subject: [PATCH] Improved PUSH-handling in Chrome Possibly fixes #1458 --- app/js/lib/push_worker.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/app/js/lib/push_worker.js b/app/js/lib/push_worker.js index 517093b7..fc479d80 100644 --- a/app/js/lib/push_worker.js +++ b/app/js/lib/push_worker.js @@ -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) { tag = 'unknown_peer' } + console.log('[SW] show notify', title, body, icon, obj) + var notificationPromise = self.registration.showNotification(title, { body: body, icon: icon,