@@ -7,6 +7,7 @@ import { invalidateQuery } from '@/src/common/query/hooks/useQuery';
77import { COLLECTION , v2 , SyncStrategy } from '@polycentric/react-native' ;
88import { router , useSegments } from 'expo-router' ;
99import { feedQueryKeys } from '../../feed/hooks/feedCache' ;
10+ import { threadQueryKey } from './useThread' ;
1011
1112type PostActions = {
1213 /**
@@ -53,6 +54,16 @@ export default function usePostActions(post: PostData): PostActions {
5354 invalidateQuery ( client , feedQueryKeys . explore ( identity ) ) ;
5455 } ;
5556
57+ const invalidateThreads = ( reply : PostData [ 'reply' ] ) => {
58+ if ( ! reply ) return ;
59+ const parents = [ reply . parentId , reply . rootId ] . filter (
60+ ( id ) : id is string => ! ! id ,
61+ ) ;
62+ for ( const parentId of new Set ( parents ) ) {
63+ invalidateQuery ( client , threadQueryKey ( parentId ) ) ;
64+ }
65+ } ;
66+
5667 return {
5768 reportAsync : async ( ) => {
5869 // TODO: discuss if we should record report events or
@@ -61,6 +72,7 @@ export default function usePostActions(post: PostData): PostActions {
6172 deleteAsync : async ( ) => {
6273 await deleteEventAtKey ( post . id ) ;
6374 invalidateFeeds ( post . identity ) ;
75+ invalidateThreads ( post . reply ) ;
6476
6577 if ( segments [ 0 ] === '[identityId]' && segments [ 1 ] === 'post' ) {
6678 // Redirect to profile
0 commit comments