Fix missing merge of FOLLOW push notifications (#596)
* Use consistent lowercase titles * Fix missing merge of FOLLOW push notifications --------- Co-authored-by: ekzyis <ek@stacker.news>
This commit is contained in:
parent
e24e2a6b20
commit
7040dbfce6
|
@ -14,11 +14,14 @@ export const notifyUserSubscribers = async ({ models, item }) => {
|
|||
followee: true
|
||||
}
|
||||
})
|
||||
const subType = isPost ? 'POST' : 'COMMENT'
|
||||
const tag = `FOLLOW-${item.userId}-${subType}`
|
||||
await Promise.allSettled(userSubs.map(({ followerId, followee }) => sendUserNotification(followerId, {
|
||||
title: `@${followee.name} ${isPost ? 'created a post' : 'replied to a post'}`,
|
||||
body: isPost ? item.title : item.text,
|
||||
item,
|
||||
tag: 'FOLLOW'
|
||||
data: { followeeName: followee.name, subType },
|
||||
tag
|
||||
})))
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
|
|
|
@ -64,11 +64,11 @@ const mergeAndShowNotification = (sw, payload, currentNotification) => {
|
|||
const amount = currentNotification.data?.amount ? currentNotification.data.amount + 1 : 2
|
||||
|
||||
let title = ''
|
||||
const newData = {}
|
||||
let newData = {}
|
||||
if (tag === 'REPLY') {
|
||||
title = `You have ${amount} new replies`
|
||||
title = `you have ${amount} new replies`
|
||||
} else if (tag === 'MENTION') {
|
||||
title = `You were mentioned ${amount} times`
|
||||
title = `you were mentioned ${amount} times`
|
||||
} else if (tag === 'REFERRAL') {
|
||||
title = `${amount} stackers joined via your referral links`
|
||||
} else if (tag === 'INVITE') {
|
||||
|
@ -79,6 +79,10 @@ const mergeAndShowNotification = (sw, payload, currentNotification) => {
|
|||
const newSats = currentSats + incomingSats
|
||||
title = `${numWithUnits(newSats, { abbreviate: false })} were deposited in your account`
|
||||
newData.sats = newSats
|
||||
} else if (tag.split('-')[0] === 'FOLLOW') {
|
||||
const { followeeName, subType } = incomingData
|
||||
title = `@${followeeName} ${subType === 'POST' ? `created ${amount} posts` : `replied ${amount} times`}`
|
||||
newData = incomingData
|
||||
}
|
||||
|
||||
// close current notification before showing new one to "merge" notifications
|
||||
|
|
Loading…
Reference in New Issue