Add profile shadow cache
This commit is contained in:
Vendored
+2
@@ -21,6 +21,7 @@ import {findAllProfilesInQueryData as findAllProfilesInProfileFollowersQueryData
|
|||||||
import {findAllProfilesInQueryData as findAllProfilesInProfileFollowsQueryData} from '#/state/queries/profile-follows'
|
import {findAllProfilesInQueryData as findAllProfilesInProfileFollowsQueryData} from '#/state/queries/profile-follows'
|
||||||
import {findAllProfilesInQueryData as findAllProfilesInSuggestedFollowsQueryData} from '#/state/queries/suggested-follows'
|
import {findAllProfilesInQueryData as findAllProfilesInSuggestedFollowsQueryData} from '#/state/queries/suggested-follows'
|
||||||
import {findAllProfilesInQueryData as findAllProfilesInSuggestedUsersQueryData} from '#/state/queries/trending/useGetSuggestedUsersQuery'
|
import {findAllProfilesInQueryData as findAllProfilesInSuggestedUsersQueryData} from '#/state/queries/trending/useGetSuggestedUsersQuery'
|
||||||
|
import {findAllProfilesInQueryData as findAllProfilesInPostThreadV2QueryData} from '#/state/queries/usePostThread/queryCache'
|
||||||
import type * as bsky from '#/types/bsky'
|
import type * as bsky from '#/types/bsky'
|
||||||
import {castAsShadow, type Shadow} from './types'
|
import {castAsShadow, type Shadow} from './types'
|
||||||
|
|
||||||
@@ -167,6 +168,7 @@ function* findProfilesInCache(
|
|||||||
yield* findAllProfilesInListConvosQueryData(queryClient, did)
|
yield* findAllProfilesInListConvosQueryData(queryClient, did)
|
||||||
yield* findAllProfilesInFeedsQueryData(queryClient, did)
|
yield* findAllProfilesInFeedsQueryData(queryClient, did)
|
||||||
yield* findAllProfilesInPostThreadQueryData(queryClient, did)
|
yield* findAllProfilesInPostThreadQueryData(queryClient, did)
|
||||||
|
yield* findAllProfilesInPostThreadV2QueryData(queryClient, did)
|
||||||
yield* findAllProfilesInKnownFollowersQueryData(queryClient, did)
|
yield* findAllProfilesInKnownFollowersQueryData(queryClient, did)
|
||||||
yield* findAllProfilesInExploreFeedPreviewsQueryData(queryClient, did)
|
yield* findAllProfilesInExploreFeedPreviewsQueryData(queryClient, did)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
type $Typed,
|
type $Typed,
|
||||||
|
type AppBskyActorDefs,
|
||||||
type AppBskyFeedDefs,
|
type AppBskyFeedDefs,
|
||||||
AppBskyUnspeccedDefs,
|
AppBskyUnspeccedDefs,
|
||||||
type AppBskyUnspeccedGetPostThreadOtherV2,
|
type AppBskyUnspeccedGetPostThreadOtherV2,
|
||||||
@@ -272,3 +273,32 @@ export function* findAllPostsInQueryData(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function* findAllProfilesInQueryData(
|
||||||
|
queryClient: QueryClient,
|
||||||
|
did: string,
|
||||||
|
): Generator<AppBskyActorDefs.ProfileViewBasic, void> {
|
||||||
|
const queryDatas =
|
||||||
|
queryClient.getQueriesData<AppBskyUnspeccedGetPostThreadV2.OutputSchema>({
|
||||||
|
queryKey: [postThreadQueryKeyRoot],
|
||||||
|
})
|
||||||
|
|
||||||
|
for (const [_queryKey, queryData] of queryDatas) {
|
||||||
|
if (!queryData) continue
|
||||||
|
|
||||||
|
const {thread} = queryData
|
||||||
|
|
||||||
|
for (const item of thread) {
|
||||||
|
if (AppBskyUnspeccedDefs.isThreadItemPost(item.value)) {
|
||||||
|
if (item.value.post.author.did === did) {
|
||||||
|
yield item.value.post.author
|
||||||
|
}
|
||||||
|
|
||||||
|
const qp = getEmbeddedPost(item.value.post.embed)
|
||||||
|
if (qp && qp.author.did === did) {
|
||||||
|
yield qp.author
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user