Merge branch 'notifications-thru-sw' into shigusegubu-vue3

This commit is contained in:
Henry Jameson 2023-11-19 14:01:09 +02:00
commit 262bb12e6b
3 changed files with 4 additions and 4 deletions

View file

@ -150,7 +150,7 @@ export const notifications = {
id,
credentials: rootState.users.currentUser.credentials
}).then(() => {
closeDesktopNotification(rootState, id)
closeDesktopNotification(rootState, { id })
})
},
dismissNotificationLocal ({ rootState, commit }, { id }) {

View file

@ -21,7 +21,7 @@ export const showDesktopNotification = (rootState, desktopNotificationOpts) => {
}
}
export const closeDesktopNotification = (rootState, id) => {
export const closeDesktopNotification = (rootState, { id }) => {
if (!('Notification' in window && window.Notification.permission === 'granted')) return
if (isSWSupported()) {
@ -33,6 +33,6 @@ export const closeAllDesktopNotifications = (rootState) => {
if (!('Notification' in window && window.Notification.permission === 'granted')) return
if (isSWSupported()) {
swCloseDesktopNotification()
swCloseDesktopNotification({})
}
}

View file

@ -88,7 +88,7 @@ export async function initServiceWorker (store) {
navigator.serviceWorker.addEventListener('message', (event) => {
const { dispatch } = store
console.log('SW MESSAGE', event)
const { type, ...rest } = event
const { type, ...rest } = event.data
switch (type) {
case 'notificationClicked':