···11-import {type AppBskyFeedDefs} from '@atproto/api'
11+import {type AppBskyFeedDefs, AtUri} from '@atproto/api'
22import {
33 type InfiniteData,
44+ type QueryClient,
45 useInfiniteQuery,
56 useQueryClient,
67} from '@tanstack/react-query'
···89import {STALE} from '#/state/queries'
910import {precachePost} from '#/state/queries/post'
1011import {useAgent} from '#/state/session'
1212+import {embedViewRecordToPostView, getEmbeddedPost} from './util'
11131214const ALSO_LIKED_URL = 'https://foryou.club/also-liked'
1315const ALSO_LIKED_PAGE_SIZE = 10
···123125 },
124126 })
125127}
128128+129129+export function* findAllPostsInQueryData(
130130+ queryClient: QueryClient,
131131+ uri: string,
132132+): Generator<AppBskyFeedDefs.PostView, void> {
133133+ const atUri = new AtUri(uri)
134134+ const queryDatas = queryClient.getQueriesData<InfiniteData<AlsoLikedPage>>({
135135+ queryKey: [RQKEY_ROOT],
136136+ })
137137+138138+ for (const [_queryKey, queryData] of queryDatas) {
139139+ if (!queryData?.pages) {
140140+ continue
141141+ }
142142+143143+ for (const page of queryData.pages) {
144144+ for (const post of page.posts) {
145145+ if (uriMatches(atUri, post)) {
146146+ yield post
147147+ }
148148+149149+ const quotedPost = getEmbeddedPost(post.embed)
150150+ if (quotedPost && uriMatches(atUri, quotedPost)) {
151151+ yield embedViewRecordToPostView(quotedPost)
152152+ }
153153+ }
154154+ }
155155+ }
156156+}
157157+158158+function uriMatches(
159159+ atUri: AtUri,
160160+ record: {uri: string; author: AppBskyFeedDefs.PostView['author']},
161161+) {
162162+ if (atUri.host.startsWith('did:')) {
163163+ return atUri.href === record.uri
164164+ }
165165+166166+ return atUri.host === record.author.handle && record.uri.endsWith(atUri.rkey)
167167+}
+4
src/state/queries/usePostThread/queryCache.ts
···1818import {findAllPostsInQueryData as findAllPostsInExploreFeedPreviewsQueryData} from '#/state/queries/explore-feed-previews'
1919import {findAllPostsInQueryData as findAllPostsInNotifsQueryData} from '#/state/queries/notifications/feed'
2020import {findAllPostsInQueryData as findAllPostsInPostQueryData} from '#/state/queries/post'
2121+import {findAllPostsInQueryData as findAllPostsInAlsoLikedQueryData} from '#/state/queries/post-also-liked'
2122import {findAllPostsInQueryData as findAllPostsInFeedQueryData} from '#/state/queries/post-feed'
2223import {findAllPostsInQueryData as findAllPostsInQuoteQueryData} from '#/state/queries/post-quotes'
2324import {findAllPostsInQueryData as findAllPostsInSearchQueryData} from '#/state/queries/search-posts'
···261262 yield postViewToThreadPlaceholder(post)
262263 }
263264 for (let post of findAllPostsInSearchQueryData(queryClient, uri)) {
265265+ yield postViewToThreadPlaceholder(post)
266266+ }
267267+ for (let post of findAllPostsInAlsoLikedQueryData(queryClient, uri)) {
264268 yield postViewToThreadPlaceholder(post)
265269 }
266270 for (let post of findAllPostsInPostQueryData(queryClient, uri)) {