Browse Source

Fixed push worker

master
Igor Zhukov 8 years ago
parent
commit
44b4228ca4
  1. 7
      app/js/lib/push_worker.js

7
app/js/lib/push_worker.js

@ -24,7 +24,10 @@ switch (location.hostname) {
self.addEventListener('push', function(event) { self.addEventListener('push', function(event) {
var obj = event.data.json() var obj = event.data.json()
console.log('[SW] push', obj) console.log('[SW] push', obj)
if (!obj.badge) {
var closeAll = obj.badge ? !fireNotification(obj, event) : true
if (closeAll) {
var promise = self.registration.showNotification('Telegram').then(function () { var promise = self.registration.showNotification('Telegram').then(function () {
return closeAllNotifications(obj) return closeAllNotifications(obj)
}).catch(function (error) { }).catch(function (error) {
@ -33,8 +36,6 @@ self.addEventListener('push', function(event) {
if ('waitUntil' in event) { if ('waitUntil' in event) {
event.waitUntil(promise) event.waitUntil(promise)
} }
} else {
fireNotification(obj, event)
} }
}) })

Loading…
Cancel
Save