Properly update badge for other unread notifications (#4052)
* decrement badge count for chats * handle decrement in `useMarkAsRead` * remove async * remove setting badge count * oops * update the number correctly * nit
This commit is contained in:
		
							parent
							
								
									5e8650a204
								
							
						
					
					
						commit
						72550df0e2
					
				
					 1 changed files with 2 additions and 8 deletions
				
			
		|  | @ -4,15 +4,14 @@ | ||||||
| 
 | 
 | ||||||
| import React from 'react' | import React from 'react' | ||||||
| import {AppState} from 'react-native' | import {AppState} from 'react-native' | ||||||
| import * as Notifications from 'expo-notifications' |  | ||||||
| import {useQueryClient} from '@tanstack/react-query' | import {useQueryClient} from '@tanstack/react-query' | ||||||
| import EventEmitter from 'eventemitter3' | import EventEmitter from 'eventemitter3' | ||||||
| 
 | 
 | ||||||
| import BroadcastChannel from '#/lib/broadcast' | import BroadcastChannel from '#/lib/broadcast' | ||||||
| import {logger} from '#/logger' | import {logger} from '#/logger' | ||||||
| import {isNative} from '#/platform/detection' |  | ||||||
| import {useMutedThreads} from '#/state/muted-threads' | import {useMutedThreads} from '#/state/muted-threads' | ||||||
| import {useAgent, useSession} from '#/state/session' | import {useAgent, useSession} from '#/state/session' | ||||||
|  | import {decrementBadgeCount} from 'lib/notifications/notifications' | ||||||
| import {useModerationOpts} from '../../preferences/moderation-opts' | import {useModerationOpts} from '../../preferences/moderation-opts' | ||||||
| import {truncateAndInvalidate} from '../util' | import {truncateAndInvalidate} from '../util' | ||||||
| import {RQKEY as RQKEY_NOTIFS} from './feed' | import {RQKEY as RQKEY_NOTIFS} from './feed' | ||||||
|  | @ -120,9 +119,7 @@ export function Provider({children}: React.PropsWithChildren<{}>) { | ||||||
|         // update & broadcast
 |         // update & broadcast
 | ||||||
|         setNumUnread('') |         setNumUnread('') | ||||||
|         broadcast.postMessage({event: ''}) |         broadcast.postMessage({event: ''}) | ||||||
|         if (isNative) { |         decrementBadgeCount(Math.min(cacheRef.current.unreadCount, 30)) | ||||||
|           Notifications.setBadgeCountAsync(0) |  | ||||||
|         } |  | ||||||
|       }, |       }, | ||||||
| 
 | 
 | ||||||
|       async checkUnread({ |       async checkUnread({ | ||||||
|  | @ -163,9 +160,6 @@ export function Provider({children}: React.PropsWithChildren<{}>) { | ||||||
|               : unreadCount === 0 |               : unreadCount === 0 | ||||||
|               ? '' |               ? '' | ||||||
|               : String(unreadCount) |               : String(unreadCount) | ||||||
|           if (isNative) { |  | ||||||
|             Notifications.setBadgeCountAsync(Math.min(unreadCount, 30)) |  | ||||||
|           } |  | ||||||
| 
 | 
 | ||||||
|           // track last sync
 |           // track last sync
 | ||||||
|           const now = new Date() |           const now = new Date() | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue