From db5315d7e4f63c1a0c0771a917a756bd5191fd0f Mon Sep 17 00:00:00 2001 From: Igor Zhukov Date: Tue, 20 Dec 2016 19:32:36 +0300 Subject: [PATCH] Improved push notifications for Chrome --- app/js/lib/push_worker.js | 10 ++++++---- app/js/services.js | 12 +++++++----- app/service_worker.js | 2 +- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/js/lib/push_worker.js b/app/js/lib/push_worker.js index e0c5a454..da1988df 100644 --- a/app/js/lib/push_worker.js +++ b/app/js/lib/push_worker.js @@ -60,13 +60,15 @@ self.addEventListener('push', function(event) { }) var closePromise = notificationPromise.catch(function () { - console.log('[SW] Closing all notifications on push') - if (userInvisibleSupported || hasActiveWindows) { + console.log('[SW] Closing all notifications on push', hasActiveWindows) + if (userInvisibleSupported) { return closeAllNotifications() } var promise = self.registration.showNotification('Telegram').then(function () { - // return closeAllNotifications() - setTimeout(closeAllNotifications, 100) + // if (hasActiveWindows) { + // return closeAllNotifications() + // } + setTimeout(closeAllNotifications, hasActiveWindows ? 0 : 100) }).catch(function (error) { console.error('Show notification error', error) }) diff --git a/app/js/services.js b/app/js/services.js index d6a0b62a..36e66c8f 100755 --- a/app/js/services.js +++ b/app/js/services.js @@ -3627,11 +3627,13 @@ angular.module('myApp.services', ['myApp.i18n', 'izhukov.utils']) $rootScope.$on('push_notification_click', function (e, notificationData) { if (notificationData.action == 'push_settings') { - $modal.open({ - templateUrl: templateUrl('settings_modal'), - controller: 'SettingsModalController', - windowClass: 'settings_modal_window mobile_modal', - backdrop: 'single' + topMessagesPromise.then(function () { + $modal.open({ + templateUrl: templateUrl('settings_modal'), + controller: 'SettingsModalController', + windowClass: 'settings_modal_window mobile_modal', + backdrop: 'single' + }) }) return } diff --git a/app/service_worker.js b/app/service_worker.js index a5c75848..82519d75 100644 --- a/app/service_worker.js +++ b/app/service_worker.js @@ -1,3 +1,3 @@ importScripts('js/lib/push_worker.js') -// Version 50 \ No newline at end of file +// Version 53 \ No newline at end of file