diff options
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() + } +} |
