invalidate author feeds after posting
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import {QueryClient} from '@tanstack/react-query'
|
||||
|
||||
import {FeedDescriptor, RQKEY_ROOT} from '#/state/queries/post-feed'
|
||||
|
||||
export function invalidateAuthorFeeds(did: string, queryClient: QueryClient) {
|
||||
const authorFilters = [
|
||||
'posts_and_author_threads',
|
||||
'posts_no_replies',
|
||||
'posts_with_replies',
|
||||
'posts_with_media',
|
||||
] as const
|
||||
for (const filter of authorFilters) {
|
||||
queryClient.invalidateQueries({
|
||||
queryKey: [
|
||||
RQKEY_ROOT,
|
||||
`author|${did}|${filter}` satisfies FeedDescriptor,
|
||||
],
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -45,8 +45,10 @@ import {RichText} from '@atproto/api'
|
||||
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
|
||||
import {msg, Trans} from '@lingui/macro'
|
||||
import {useLingui} from '@lingui/react'
|
||||
import {useQueryClient} from '@tanstack/react-query'
|
||||
|
||||
import * as apilib from '#/lib/api/index'
|
||||
import {invalidateAuthorFeeds} from '#/lib/api/invalidate-author-feeds'
|
||||
import {until} from '#/lib/async/until'
|
||||
import {MAX_GRAPHEME_LENGTH} from '#/lib/constants'
|
||||
import {
|
||||
@@ -161,6 +163,7 @@ export const ComposePost = ({
|
||||
const {closeAllDialogs} = useDialogStateControlContext()
|
||||
const {closeAllModals} = useModalControls()
|
||||
const t = useTheme()
|
||||
const queryClient = useQueryClient()
|
||||
|
||||
const [isKeyboardVisible] = useIsKeyboardVisible({iosUseWillEvents: true})
|
||||
const [isProcessing, setIsProcessing] = useState(false)
|
||||
@@ -420,6 +423,7 @@ export const ComposePost = ({
|
||||
const thread = res.data.thread
|
||||
return AppBskyFeedDefs.isThreadViewPost(thread)
|
||||
})
|
||||
invalidateAuthorFeeds(currentAccount?.did ?? '', queryClient)
|
||||
} catch (waitErr: any) {
|
||||
logger.error(waitErr, {
|
||||
message: `Waiting for app view failed`,
|
||||
@@ -513,6 +517,8 @@ export const ComposePost = ({
|
||||
videoUploadState.asset,
|
||||
videoUploadState.pendingPublish,
|
||||
videoUploadState.status,
|
||||
queryClient,
|
||||
currentAccount?.did,
|
||||
],
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user