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