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

@ -483,6 +483,45 @@ export function* findAllPostsInQueryData(
}
}
export function* findAllProfilesInQueryData(
queryClient: QueryClient,
did: string,
): Generator<AppBskyActorDefs.ProfileView, undefined> {
const queryDatas = queryClient.getQueriesData<
InfiniteData<FeedPageUnselected>
>({
queryKey: [RQKEY_ROOT],
})
for (const [_queryKey, queryData] of queryDatas) {
if (!queryData?.pages) {
continue
}
for (const page of queryData?.pages) {
for (const item of page.feed) {
if (item.post.author.did === did) {
yield item.post.author
}
const quotedPost = getEmbeddedPost(item.post.embed)
if (quotedPost?.author.did === did) {
yield quotedPost.author
}
if (
AppBskyFeedDefs.isPostView(item.reply?.parent) &&
item.reply?.parent?.author.did === did
) {
yield item.reply.parent.author
}
if (
AppBskyFeedDefs.isPostView(item.reply?.root) &&
item.reply?.root?.author.did === did
) {
yield item.reply.root.author
}
}
}
}
}
function assertSomePostsPassModeration(feed: AppBskyFeedDefs.FeedViewPost[]) {
// no posts in this feed
if (feed.length === 0) return true