Merge pull request #718 from torhve/serviceworker
Implement click handler for the notification
This commit is contained in:
commit
d06219102c
2 changed files with 25 additions and 1 deletions
|
@ -41,7 +41,7 @@ weechat.factory('notifications', ['$rootScope', '$log', 'models', 'settings', fu
|
||||||
registration.showNotification(title, {
|
registration.showNotification(title, {
|
||||||
body: body,
|
body: body,
|
||||||
icon: 'assets/img/glowing_bear_128x128.png',
|
icon: 'assets/img/glowing_bear_128x128.png',
|
||||||
vibrate: [200, 100, 200, 100, 200, 100, 200],
|
vibrate: [200, 100],
|
||||||
tag: 'gb-highlight-vib'
|
tag: 'gb-highlight-vib'
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,3 +20,27 @@ this.addEventListener('push', function(event) {
|
||||||
tag: 'my-tag'
|
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/');
|
||||||
|
}
|
||||||
|
*/
|
||||||
|
}));
|
||||||
|
};
|
||||||
|
|
Loading…
Reference in a new issue