diff options
| author | Henry Jameson <me@hjkos.com> | 2023-11-13 17:29:25 +0200 |
|---|---|---|
| committer | Henry Jameson <me@hjkos.com> | 2023-11-13 17:29:25 +0200 |
| commit | ec2937ec1f3b0ae153f79604eb35b57ffe0f9af2 (patch) | |
| tree | 43f77d71432accfbd90dc9747224c22c1393293c /src/services/desktop_notification_utils/desktop_notification_utils.js | |
| parent | c059f4a7ee16c0128c348c43c9d468e7cfdb5ef7 (diff) | |
add options for marking single notification as read
Diffstat (limited to 'src/services/desktop_notification_utils/desktop_notification_utils.js')
| -rw-r--r-- | src/services/desktop_notification_utils/desktop_notification_utils.js | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/src/services/desktop_notification_utils/desktop_notification_utils.js b/src/services/desktop_notification_utils/desktop_notification_utils.js index eb58f39b..dbca4173 100644 --- a/src/services/desktop_notification_utils/desktop_notification_utils.js +++ b/src/services/desktop_notification_utils/desktop_notification_utils.js @@ -1,4 +1,8 @@ -import { showDesktopNotification as swDesktopNotification, isSWSupported } from '../sw/sw.js' +import { + showDesktopNotification as swDesktopNotification, + closeDesktopNotification as swCloseDesktopNotification, + isSWSupported +} from '../sw/sw.js' const state = { failCreateNotif: false } export const showDesktopNotification = (rootState, desktopNotificationOpts) => { @@ -16,3 +20,19 @@ export const showDesktopNotification = (rootState, desktopNotificationOpts) => { } } } + +export const closeDesktopNotification = (rootState, id) => { + if (!('Notification' in window && window.Notification.permission === 'granted')) return + + if (isSWSupported()) { + swCloseDesktopNotification({ id }) + } +} + +export const closeAllDesktopNotifications = (rootState) => { + if (!('Notification' in window && window.Notification.permission === 'granted')) return + + if (isSWSupported()) { + swCloseDesktopNotification() + } +} |
