2025-09-12 09:24:22 -07:00
|
|
|
const NOTIFICATIONS = {
|
2026-02-04 11:28:00 -08:00
|
|
|
_notifications: [],
|
|
|
|
|
|
2025-09-12 09:24:22 -07:00
|
|
|
send: function (message, options = {}) {
|
|
|
|
|
if (!Notification || Notification.permission !== "granted") {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const notification = new Notification(message, options);
|
2026-02-04 11:28:00 -08:00
|
|
|
this._notifications.push( notification );
|
2025-09-12 09:24:22 -07:00
|
|
|
return notification;
|
|
|
|
|
},
|
|
|
|
|
|
2026-02-04 11:28:00 -08:00
|
|
|
close: function() {
|
|
|
|
|
for ( const notification of this._notifications ) {
|
|
|
|
|
notification?.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
this._notifications.length = 0;
|
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
request_permission: function () {
|
2025-09-12 09:24:22 -07:00
|
|
|
if (Notification && Notification.permission === "granted") {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Notification.requestPermission();
|
|
|
|
|
},
|
|
|
|
|
};
|