Skip to content

Commit 1166f17

Browse files
committed
fix: ios push notifications
1 parent 146b602 commit 1166f17

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

sw/eventListener.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ const storage = new ServiceWorkerStorage('sw:storage', 1)
1111
let messageChannelPort
1212
let actionChannelPort
1313

14+
// TODO 756.2 Fix iOS check, initialValue isn't updated if iOS is true
1415
// operating system. the value will be received via a STORE_OS message from app since service workers don't have access to window.navigator
1516
let os = ''
1617
const iOS = () => os === 'iOS'
@@ -131,7 +132,7 @@ const mergeAndShowNotification = async (sw, payload, currentNotifications, tag,
131132
}
132133
const newPayload = { ...data, amount: newAmount, sats: newSats }
133134
return newPayload
134-
}, { ...incomingData, amount: initialAmount })
135+
}, { ...incomingData, amount: 1 }) // 1 is hard coded to test iOS scenario, should be initialValue
135136

136137
log(`[sw:push] ${nid} - merged payload: ${JSON.stringify(mergedPayload)}`)
137138

@@ -142,7 +143,7 @@ const mergeAndShowNotification = async (sw, payload, currentNotifications, tag,
142143
if (compareTag === 'REPLY') {
143144
title = `you have ${amount} new replies`
144145
} else if (compareTag === 'MENTION') {
145-
title = `you were mentioned ${amount} times`
146+
title = `you were mentioned ${amount} times` // PROPOSAL: url should be notifications page
146147
} else if (compareTag === 'ITEM_MENTION') {
147148
title = `your items were mentioned ${amount} times`
148149
} else if (compareTag === 'REFERRAL') {
@@ -175,6 +176,9 @@ const mergeAndShowNotification = async (sw, payload, currentNotifications, tag,
175176
return await sw.registration.showNotification(title, options)
176177
}
177178

179+
// TODO 756.3 sometimes you get sent to very old threads, this is because the notification is not updated
180+
// PROPOSAL close all notifications with the same tag
181+
178182
export function onNotificationClick (sw) {
179183
return (event) => {
180184
const url = event.notification.data?.url

0 commit comments

Comments
 (0)