diff --git a/public/reminders.js b/public/reminders.js index 27bdd7a..8fbb588 100644 --- a/public/reminders.js +++ b/public/reminders.js @@ -23,7 +23,8 @@ async function remindersInit() {
Morning time
` : ''} ${allowed('calendar') ? `
How early
` : ''} -
Send a test to every device that is on
`; +
Send a test to every device that is on
+
Dismiss every notification from NE Hub still showing on this device
`; const on1 = document.getElementById('remon'); on1.onchange = async () => { try { @@ -42,5 +43,12 @@ async function remindersInit() { }; const pref = (id, key, get) => { const el = document.getElementById(id); if (el) el.onchange = () => post('prefs', { [key]: get(el) }).catch(e => toast(e.message)); }; pref('remt', 'tasks', e => e.checked); pref('remat', 'tasksAt', e => e.value); pref('reme', 'events', e => e.checked); pref('remm', 'eventMins', e => +e.value); + document.getElementById('remclear').onclick = async () => { + try { + const list = await reg.getNotifications(); list.forEach(n => n.close()); + try { navigator.clearAppBadge && await navigator.clearAppBadge(); } catch {} + toast(list.length ? 'Cleared ' + list.length + (list.length === 1 ? ' notification' : ' notifications') : 'No notifications to clear'); + } catch (e) { toast(e.message); } + }; document.getElementById('remtest').onclick = () => post('test', {}).then(() => toast('Test sent')).catch(e => toast(e.message)); }