Skip to content

Commit

Permalink
include notifications url for merged payloads
Browse files Browse the repository at this point in the history
  • Loading branch information
Soxasora committed Jan 6, 2025
1 parent e1e3a24 commit 799412f
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions sw/eventListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ServiceWorkerStorage from 'serviceworker-storage'
import { numWithUnits } from '@/lib/format'
import { CLEAR_NOTIFICATIONS, clearAppBadge, setAppBadge } from '@/lib/badge'
import { ACTION_PORT, DELETE_SUBSCRIPTION, MESSAGE_PORT, STORE_OS, STORE_SUBSCRIPTION, SYNC_SUBSCRIPTION } from '@/components/serviceworker'
// import { getLogger } from '@/lib/logger'
import { getLogger } from '@/lib/logger'

// we store existing push subscriptions to keep them in sync with server
const storage = new ServiceWorkerStorage('sw:storage', 1)
Expand Down Expand Up @@ -97,6 +97,7 @@ const mergeNotification = (event, sw, payload, currentNotifications, tag, nid) =
// currentNotifications.reduce causes iOS to sum n notifications + initialAmount which is already n notifications
const mergedPayload = {
...incomingData,
url: '/notifications', // when merged we should always go to the notifications page
amount: initialAmount + 1,
sats: initialSats + incomingData.sats
}
Expand Down Expand Up @@ -131,7 +132,7 @@ const mergeNotification = (event, sw, payload, currentNotifications, tag, nid) =
}
// logger.info(`[sw:push] ${nid} - calculated title: ${title}`)

const options = { icon: payload.options?.icon, tag, data: { url: '/notifications', ...mergedPayload } }
const options = { icon: payload.options?.icon, tag, data: { ...mergedPayload } }
// logger.info(`[sw:push] ${nid} - show notification with title "${title}"`)
return { title, options } // send the new, merged, payload
}
Expand Down

0 comments on commit 799412f

Please sign in to comment.