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

@ -17,7 +17,7 @@
*/
import {useEffect, useRef} from 'react'
import {AppBskyFeedDefs} from '@atproto/api'
import {AppBskyActorDefs, AppBskyFeedDefs} from '@atproto/api'
import {
InfiniteData,
QueryClient,
@ -162,3 +162,28 @@ export function* findAllPostsInQueryData(
}
}
}
export function* findAllProfilesInQueryData(
queryClient: QueryClient,
did: string,
): Generator<AppBskyActorDefs.ProfileView, void> {
const queryDatas = queryClient.getQueriesData<InfiniteData<FeedPage>>({
queryKey: [RQKEY_ROOT],
})
for (const [_queryKey, queryData] of queryDatas) {
if (!queryData?.pages) {
continue
}
for (const page of queryData?.pages) {
for (const item of page.items) {
if (item.subject?.author.did === did) {
yield item.subject.author
}
const quotedPost = getEmbeddedPost(item.subject?.embed)
if (quotedPost?.author.did === did) {
yield quotedPost.author
}
}
}
}
}