mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-01 13:37:47 +00:00
Add dismiss functionality to html5 notifications. (#2435)
* Add dismiss function to notifications. * fix let -> const
This commit is contained in:
parent
a2ef8bbe70
commit
326931277e
@ -72,6 +72,18 @@ function initPushNotifications() {
|
||||
var data;
|
||||
if (event.data) {
|
||||
data = event.data.json();
|
||||
if (data.dismiss) {
|
||||
event.waitUntil(
|
||||
self.registration
|
||||
.getNotifications({ tag: data.tag })
|
||||
.then(function(notifications) {
|
||||
for (const n of notifications) {
|
||||
n.close();
|
||||
}
|
||||
})
|
||||
);
|
||||
return;
|
||||
}
|
||||
event.waitUntil(
|
||||
self.registration
|
||||
.showNotification(data.title, data)
|
||||
|
Loading…
x
Reference in New Issue
Block a user