Skip to content

Commit

Permalink
Properly update badge for other unread notifications (#4052)
Browse files Browse the repository at this point in the history
* decrement badge count for chats

* handle decrement in `useMarkAsRead`

* remove async

* remove setting badge count

* oops

* update the number correctly

* nit
  • Loading branch information
haileyok authored May 16, 2024
1 parent 5e8650a commit 72550df
Showing 1 changed file with 2 additions and 8 deletions.
10 changes: 2 additions & 8 deletions src/state/queries/notifications/unread.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,14 @@

import React from 'react'
import {AppState} from 'react-native'
import * as Notifications from 'expo-notifications'
import {useQueryClient} from '@tanstack/react-query'
import EventEmitter from 'eventemitter3'

import BroadcastChannel from '#/lib/broadcast'
import {logger} from '#/logger'
import {isNative} from '#/platform/detection'
import {useMutedThreads} from '#/state/muted-threads'
import {useAgent, useSession} from '#/state/session'
import {decrementBadgeCount} from 'lib/notifications/notifications'
import {useModerationOpts} from '../../preferences/moderation-opts'
import {truncateAndInvalidate} from '../util'
import {RQKEY as RQKEY_NOTIFS} from './feed'
Expand Down Expand Up @@ -120,9 +119,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
// update & broadcast
setNumUnread('')
broadcast.postMessage({event: ''})
if (isNative) {
Notifications.setBadgeCountAsync(0)
}
decrementBadgeCount(Math.min(cacheRef.current.unreadCount, 30))
},

async checkUnread({
Expand Down Expand Up @@ -163,9 +160,6 @@ export function Provider({children}: React.PropsWithChildren<{}>) {
: unreadCount === 0
? ''
: String(unreadCount)
if (isNative) {
Notifications.setBadgeCountAsync(Math.min(unreadCount, 30))
}

// track last sync
const now = new Date()
Expand Down

0 comments on commit 72550df

Please sign in to comment.