From ec2937ec1f3b0ae153f79604eb35b57ffe0f9af2 Mon Sep 17 00:00:00 2001 From: Henry Jameson Date: Mon, 13 Nov 2023 17:29:25 +0200 Subject: add options for marking single notification as read --- src/services/sw/sw.js | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'src/services/sw/sw.js') diff --git a/src/services/sw/sw.js b/src/services/sw/sw.js index 2875d36e..d4ae8f4f 100644 --- a/src/services/sw/sw.js +++ b/src/services/sw/sw.js @@ -96,6 +96,15 @@ export async function showDesktopNotification (content) { sw.postMessage({ type: 'desktopNotification', content }) } +export async function closeDesktopNotification ({ id }) { + const { active: sw } = await window.navigator.serviceWorker.getRegistration() + if (id >= 0) { + sw.postMessage({ type: 'desktopNotificationClose', content: { id } }) + } else { + sw.postMessage({ type: 'desktopNotificationClose', content: { all: true } }) + } +} + export async function updateFocus () { const { active: sw } = await window.navigator.serviceWorker.getRegistration() sw.postMessage({ type: 'updateFocus' }) -- cgit v1.2.3-70-g09d2