From 1565c0e72d29826b169b5059984c421139bc2500 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Tue, 22 Dec 2015 14:03:30 +0100 Subject: [PATCH 1/2] less vibrations --- js/notifications.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/notifications.js b/js/notifications.js index 2ed9d1b..fd56fa3 100644 --- a/js/notifications.js +++ b/js/notifications.js @@ -41,7 +41,7 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', fu registration.showNotification(title, { body: body, icon: 'assets/img/glowing_bear_128x128.png', - vibrate: [200, 100, 200, 100, 200, 100, 200], + vibrate: [200, 100], tag: 'gb-highlight-vib' }); }); From 952da6d9dddb311e2ff8f0a1c53d7219a3b2cda9 Mon Sep 17 00:00:00 2001 From: Tor Hveem Date: Tue, 22 Dec 2015 14:40:01 +0100 Subject: [PATCH 2/2] implement on notification click --- serviceworker.js | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/serviceworker.js b/serviceworker.js index 99f97c5..7a549b6 100644 --- a/serviceworker.js +++ b/serviceworker.js @@ -20,3 +20,27 @@ this.addEventListener('push', function(event) { tag: 'my-tag' })); }); + +this.onnotificationclick = function(event) { + // Android doesn't close the notification when you click on it + // See: http://crbug.com/463146 + event.notification.close(); + + // This looks to see if the current is already open and + // focuses if it is + event.waitUntil(clients.matchAll({ + type: "window" + }).then(function(clientList) { + for (var i = 0; i < clientList.length; i++) { + var client = clientList[i]; + if ('focus' in client) { + return client.focus(); + } + } + /* + if (clients.openWindow) { + return clients.openWindow('/glowing-bear/'); + } + */ + })); +};