Make closing notifications work

This commit is contained in:
binwiederhier
2026-01-14 21:17:21 -05:00
parent 96638b516c
commit ff2b8167b4
3 changed files with 31 additions and 3 deletions

View File

@@ -31,6 +31,21 @@ class Notifier {
);
}
async cancel(notification) {
if (!this.supported()) {
return;
}
try {
const tag = notification.sequence_id || notification.id;
console.log(`[Notifier] Cancelling notification with ${tag}`);
const registration = await this.serviceWorkerRegistration();
const notifications = await registration.getNotifications({ tag });
notifications.forEach((notification) => notification.close());
} catch (e) {
console.log(`[Notifier] Error cancelling notification`, e);
}
}
async playSound() {
// Play sound
const sound = await prefs.sound();