Skip to content

Commit

Permalink
hotfix: track amount via notification.length
Browse files Browse the repository at this point in the history
  • Loading branch information
Soxasora committed Jan 6, 2025
1 parent f51869a commit a37992e
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion sw/eventListener.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ export function onPush (sw) {
} else { // Check if there are already notifications with the same tag and merge them
// logger.info(`[${nid}] checking for existing notification with tag ${tag}`)
promises.push(sw.registration.getNotifications({ tag }).then((notifications) => {
// logger.info(`[${nid}] found ${notifications.length} notifications with tag ${tag}`)
if (notifications.length) {
// logger.info(`[${nid}] found ${notifications.length} notifications with tag ${tag}`)
payload = mergeNotification(event, sw, payload, notifications, tag, nid)
Expand Down Expand Up @@ -89,7 +90,7 @@ const mergeNotification = (event, sw, payload, currentNotifications, tag, nid) =
// tags that need to know the sum of sats of notifications with same tag for merging
const SUM_SATS_TAGS = ['DEPOSIT', 'WITHDRAWAL']
// this should reflect the amount of notifications that were already merged before
const initialAmount = currentNotifications[0]?.data?.amount || 1
const initialAmount = currentNotifications.length || 1
const initialSats = currentNotifications[0]?.data?.sats || 0
// logger.info(`[sw:push] ${nid} - initial amount: ${initialAmount}`)
// logger.info(`[sw:push] ${nid} - initial sats: ${initialSats}`)
Expand Down

0 comments on commit a37992e

Please sign in to comment.