mirror of
https://github.com/home-assistant/frontend.git
synced 2025-08-02 14:07:55 +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;
|
var data;
|
||||||
if (event.data) {
|
if (event.data) {
|
||||||
data = event.data.json();
|
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(
|
event.waitUntil(
|
||||||
self.registration
|
self.registration
|
||||||
.showNotification(data.title, data)
|
.showNotification(data.title, data)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user