Improve notification load behaviors (#1943)

* Dont use the stale cache for notifs-feed

* Add a delay to marking all read to avoid marking upcoming posts as read

* Trigger automatic notifications refresh when navigating to the tab, in certain conditions
This commit is contained in:
Paul Frazee 2023-11-16 18:27:05 -08:00 committed by GitHub
parent 357c752a21
commit e358c3cc30
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
5 changed files with 34 additions and 6 deletions

View file

@ -45,6 +45,8 @@ import {useUnreadNotifications} from '#/state/queries/notifications/unread'
import {useComposerControls} from '#/state/shell/composer'
import {useFetchHandle} from '#/state/queries/handle'
import {emitSoftReset} from '#/state/events'
import {useQueryClient} from '@tanstack/react-query'
import {RQKEY as NOTIFS_RQKEY} from '#/state/queries/notifications/feed'
function ProfileCard() {
const {currentAccount} = useSession()
@ -118,6 +120,7 @@ interface NavItemProps {
}
function NavItem({count, href, icon, iconFilled, label}: NavItemProps) {
const pal = usePalette('default')
const queryClient = useQueryClient()
const {currentAccount} = useSession()
const {isDesktop, isTablet} = useWebMediaQueries()
const [pathName] = React.useMemo(() => router.matchPath(href), [href])
@ -143,10 +146,16 @@ function NavItem({count, href, icon, iconFilled, label}: NavItemProps) {
if (isCurrent) {
emitSoftReset()
} else {
if (href === '/notifications') {
// fetch new notifs on view
queryClient.invalidateQueries({
queryKey: NOTIFS_RQKEY(),
})
}
onPress()
}
},
[onPress, isCurrent],
[onPress, isCurrent, queryClient, href],
)
return (