Skip to content
This repository has been archived by the owner on Jun 17, 2021. It is now read-only.

Commit

Permalink
Improved PUSH-handling in Chrome
Browse files Browse the repository at this point in the history
Possibly fixes zhukov#1458
  • Loading branch information
zhukov committed Dec 30, 2017
1 parent ac815f7 commit 7d408a6
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions app/js/lib/push_worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 7d408a6

Please sign in to comment.