fix `findAll*` type in `post-thread` (#4986)
parent
425dd5f27f
commit
1f657b3ac5
|
@ -85,13 +85,15 @@ export type ThreadNode =
|
|||
|
||||
export type ThreadModerationCache = WeakMap<ThreadNode, ModerationDecision>
|
||||
|
||||
export type PostThreadQueryData = {
|
||||
thread: ThreadNode
|
||||
threadgate?: AppBskyFeedDefs.ThreadgateView
|
||||
}
|
||||
|
||||
export function usePostThreadQuery(uri: string | undefined) {
|
||||
const queryClient = useQueryClient()
|
||||
const agent = useAgent()
|
||||
return useQuery<
|
||||
{thread: ThreadNode; threadgate?: AppBskyFeedDefs.ThreadgateView},
|
||||
Error
|
||||
>({
|
||||
return useQuery<PostThreadQueryData, Error>({
|
||||
gcTime: 0,
|
||||
queryKey: RQKEY(uri || ''),
|
||||
async queryFn() {
|
||||
|
@ -384,14 +386,15 @@ export function* findAllPostsInQueryData(
|
|||
): Generator<ThreadNode, void> {
|
||||
const atUri = new AtUri(uri)
|
||||
|
||||
const queryDatas = queryClient.getQueriesData<ThreadNode>({
|
||||
const queryDatas = queryClient.getQueriesData<PostThreadQueryData>({
|
||||
queryKey: [RQKEY_ROOT],
|
||||
})
|
||||
for (const [_queryKey, queryData] of queryDatas) {
|
||||
if (!queryData) {
|
||||
continue
|
||||
}
|
||||
for (const item of traverseThread(queryData)) {
|
||||
const {thread} = queryData
|
||||
for (const item of traverseThread(thread)) {
|
||||
if (item.type === 'post' && didOrHandleUriMatches(atUri, item.post)) {
|
||||
const placeholder = threadNodeToPlaceholderThread(item)
|
||||
if (placeholder) {
|
||||
|
@ -423,14 +426,15 @@ export function* findAllProfilesInQueryData(
|
|||
queryClient: QueryClient,
|
||||
did: string,
|
||||
): Generator<AppBskyActorDefs.ProfileView, void> {
|
||||
const queryDatas = queryClient.getQueriesData<ThreadNode>({
|
||||
const queryDatas = queryClient.getQueriesData<PostThreadQueryData>({
|
||||
queryKey: [RQKEY_ROOT],
|
||||
})
|
||||
for (const [_queryKey, queryData] of queryDatas) {
|
||||
if (!queryData) {
|
||||
continue
|
||||
}
|
||||
for (const item of traverseThread(queryData)) {
|
||||
const {thread} = queryData
|
||||
for (const item of traverseThread(thread)) {
|
||||
if (item.type === 'post' && item.post.author.did === did) {
|
||||
yield item.post.author
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue