Disable badge incrementing for DMs (#4088)

* disable badge increments for dms

* revert decrementing in js for dms

* reset badge on read notifications

* remove some other code

* prevent duplicate notification events
This commit is contained in:
Hailey 2024-05-17 16:05:32 -07:00 committed by GitHub
parent 49314e2d1f
commit d2c81c9d3d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 24 additions and 28 deletions

View file

@ -15,7 +15,6 @@ import {useCurrentConvoId} from '#/state/messages/current-convo-id'
import {useModerationOpts} from '#/state/preferences/moderation-opts'
import {DM_SERVICE_HEADERS} from '#/state/queries/messages/const'
import {useAgent, useSession} from '#/state/session'
import {decrementBadgeCount} from 'lib/notifications/notifications'
export const RQKEY = ['convo-list']
type RQPageParam = string | undefined
@ -135,18 +134,10 @@ export function useOnMarkAsRead() {
return useCallback(
(chatId: string) => {
queryClient.setQueryData(RQKEY, (old: ConvoListQueryData) => {
return optimisticUpdate(chatId, old, convo => {
// We only want to decrement the badge by one no matter the unread count, since we only increment once per
// sender regardless of message count
if (convo.unreadCount > 0) {
decrementBadgeCount(1)
}
return {
...convo,
unreadCount: 0,
}
})
return optimisticUpdate(chatId, old, convo => ({
...convo,
unreadCount: 0,
}))
})
},
[queryClient],

View file

@ -119,7 +119,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
// update & broadcast
setNumUnread('')
broadcast.postMessage({event: ''})
decrementBadgeCount(Math.min(cacheRef.current.unreadCount, 30))
decrementBadgeCount('reset')
},
async checkUnread({