This commit is contained in:
Eric Bailey 2024-05-30 23:56:09 -05:00 committed by GitHub
parent 89c9fd3be1
commit d614f6cb71
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 149 additions and 11 deletions

View file

@ -1,4 +1,8 @@
import {AppBskyFeedDefs, AppBskyFeedSearchPosts} from '@atproto/api'
import {
AppBskyActorDefs,
AppBskyFeedDefs,
AppBskyFeedSearchPosts,
} from '@atproto/api'
import {
InfiniteData,
QueryClient,
@ -75,3 +79,30 @@ export function* findAllPostsInQueryData(
}
}
}
export function* findAllProfilesInQueryData(
queryClient: QueryClient,
did: string,
): Generator<AppBskyActorDefs.ProfileView, undefined> {
const queryDatas = queryClient.getQueriesData<
InfiniteData<AppBskyFeedSearchPosts.OutputSchema>
>({
queryKey: [searchPostsQueryKeyRoot],
})
for (const [_queryKey, queryData] of queryDatas) {
if (!queryData?.pages) {
continue
}
for (const page of queryData?.pages) {
for (const post of page.posts) {
if (post.author.did === did) {
yield post.author
}
const quotedPost = getEmbeddedPost(post.embed)
if (quotedPost?.author.did === did) {
yield quotedPost.author
}
}
}
}
}