[🐴] Unread messages badge (#3901)

* add badge

* move stringify logic to hook

* add mutation hooks

* optimistic mark convo as read

* don't count muted chats

* Integrate new context

* Integrate mark unread mutation

* Remove unused edit

---------

Co-authored-by: Eric Bailey <git@esb.lol>
This commit is contained in:
Samuel Newman 2024-05-08 03:23:09 +01:00 committed by GitHub
parent 0c41b3188a
commit 4fe5a869c3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 162 additions and 8 deletions

View file

@ -27,6 +27,7 @@ import {getTabState, TabState} from '#/lib/routes/helpers'
import {useGate} from '#/lib/statsig/statsig'
import {s} from '#/lib/styles'
import {emitSoftReset} from '#/state/events'
import {useUnreadMessageCount} from '#/state/queries/messages/list-converations'
import {useUnreadNotifications} from '#/state/queries/notifications/unread'
import {useProfileQuery} from '#/state/queries/profile'
import {useSession} from '#/state/session'
@ -68,6 +69,7 @@ export function BottomBar({navigation}: BottomTabBarProps) {
isAtMessages,
} = useNavigationTabState()
const numUnreadNotifications = useUnreadNotifications()
const numUnreadMessages = useUnreadMessageCount()
const {footerMinimalShellTransform} = useMinimalShellMode()
const {data: profile} = useProfileQuery({did: currentAccount?.did})
const {requestSwitchToAccount} = useLoggedOutViewControls()
@ -257,9 +259,15 @@ export function BottomBar({navigation}: BottomTabBarProps) {
)
}
onPress={onPressMessages}
notificationCount={numUnreadMessages.numUnread}
accessible={true}
accessibilityRole="tab"
accessibilityLabel={_(msg`Messages`)}
accessibilityHint=""
accessibilityHint={
numUnreadMessages.count > 0
? `${numUnreadMessages.numUnread} unread`
: ''
}
/>
)}
<Btn