Maintain some feed data to avoid needless glimmers (#2054)

This commit is contained in:
Paul Frazee 2023-11-30 18:49:23 -08:00 committed by GitHub
parent 9fa90bb8d9
commit 826cbbd4bf
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 40 additions and 23 deletions

View file

@ -23,6 +23,7 @@ import {useLingui} from '@lingui/react'
import {useSession} from '#/state/session'
import {useComposerControls} from '#/state/shell/composer'
import {listenSoftReset, emitSoftReset} from '#/state/events'
import {truncateAndInvalidate} from '#/state/queries/util'
const POLL_FREQ = 30e3 // 30sec
@ -62,7 +63,7 @@ export function FeedPage({
const onSoftReset = React.useCallback(() => {
if (isPageFocused) {
scrollToTop()
queryClient.resetQueries({queryKey: FEED_RQKEY(feed)})
truncateAndInvalidate(queryClient, FEED_RQKEY(feed))
setHasNew(false)
}
}, [isPageFocused, scrollToTop, queryClient, feed, setHasNew])
@ -83,7 +84,7 @@ export function FeedPage({
const onPressLoadLatest = React.useCallback(() => {
scrollToTop()
queryClient.resetQueries({queryKey: FEED_RQKEY(feed)})
truncateAndInvalidate(queryClient, FEED_RQKEY(feed))
setHasNew(false)
}, [scrollToTop, feed, queryClient, setHasNew])