check if we are blocked when opening a profile, reset posts cache if we are
This commit is contained in:
parent
4f28028569
commit
dd3229d900
2 changed files with 29 additions and 2 deletions
|
@ -22,6 +22,7 @@ import {RQKEY as RQKEY_MY_MUTED} from './my-muted-accounts'
|
|||
import {RQKEY as RQKEY_MY_BLOCKED} from './my-blocked-accounts'
|
||||
import {STALE} from '#/state/queries'
|
||||
import {track} from '#/lib/analytics/analytics'
|
||||
import {queryClient} from '#/lib/react-query'
|
||||
|
||||
export const RQKEY = (did: string) => ['profile', did]
|
||||
export const profilesQueryKey = (handles: string[]) => ['profiles', handles]
|
||||
|
@ -375,8 +376,9 @@ function useProfileBlockMutation() {
|
|||
{subject: did, createdAt: new Date().toISOString()},
|
||||
)
|
||||
},
|
||||
onSuccess() {
|
||||
onSuccess(_, {did}) {
|
||||
queryClient.invalidateQueries({queryKey: RQKEY_MY_BLOCKED()})
|
||||
resetProfilePostsQueries(did, 1000)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
@ -394,6 +396,9 @@ function useProfileUnblockMutation() {
|
|||
rkey,
|
||||
})
|
||||
},
|
||||
onSuccess(_, {did}) {
|
||||
resetProfilePostsQueries(did, 1000)
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -426,3 +431,15 @@ export function* findAllProfilesInQueryData(
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
export function resetProfilePostsQueries(did: string, timeout = 0) {
|
||||
setTimeout(() => {
|
||||
queryClient.resetQueries({
|
||||
predicate: query =>
|
||||
!!(
|
||||
query.queryKey[0] === 'post-feed' &&
|
||||
(query.queryKey[1] as string)?.includes(did)
|
||||
),
|
||||
})
|
||||
}, timeout)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue