···153153 const alsoLikedFeedEnabled = useAlsoLikedFeedEnabled()
154154 const alsoLikedAnchorUri =
155155 anchor?.type === 'threadPost' && isRoot ? anchor.value.post.uri : undefined
156156+ const [deferParents, setDeferParents] = useState(true)
157157+ const [alsoLikedReady, setAlsoLikedReady] = useState(false)
158158+ useEffect(() => {
159159+ const shouldEnable =
160160+ Boolean(alsoLikedAnchorUri) &&
161161+ alsoLikedFeedEnabled &&
162162+ !thread.state.isPlaceholderData &&
163163+ !deferParents
164164+165165+ if (!shouldEnable) {
166166+ setAlsoLikedReady(false)
167167+ return
168168+ }
169169+170170+ const timeout = setTimeout(() => {
171171+ startTransition(() => {
172172+ setAlsoLikedReady(true)
173173+ })
174174+ }, 0)
175175+176176+ return () => clearTimeout(timeout)
177177+ }, [
178178+ alsoLikedAnchorUri,
179179+ alsoLikedFeedEnabled,
180180+ deferParents,
181181+ thread.state.isPlaceholderData,
182182+ ])
156183 const alsoLiked = usePostAlsoLikedQuery(alsoLikedAnchorUri, {
157157- enabled: Boolean(alsoLikedAnchorUri) && alsoLikedFeedEnabled,
184184+ enabled: alsoLikedReady,
158185 })
159186 const alsoLikedPosts = useMemo(() => {
160187 const seen = new Set<string>()
···188215 * On web, `onContentSizeChange` is used to get ahead of next paint and handle
189216 * this scrolling.
190217 */
191191- const [deferParents, setDeferParents] = useState(true)
192218 /**
193219 * Used to flag whether we should scroll to the anchor post. On a cold load,
194220 * this is always true. And when a user changes thread parameters, we also
···355381 }
356382 if (
357383 alsoLikedAnchorUri &&
358358- alsoLikedFeedEnabled &&
384384+ alsoLikedReady &&
359385 !alsoLiked.isLoading &&
360386 !alsoLiked.isFetchingNextPage &&
361387 alsoLiked.hasNextPage
···633659 ListFooterComponent={
634660 <ThreadAlsoLiked
635661 posts={alsoLikedPosts}
636636- enabled={Boolean(alsoLikedAnchorUri) && alsoLikedFeedEnabled}
662662+ enabled={alsoLikedReady}
637663 isLoading={alsoLiked.isLoading}
638664 isFetchingNextPage={alsoLiked.isFetchingNextPage}
639665 error={alsoLiked.error}
+4
src/state/cache/post-shadow.ts
···1111import {findAllPostsInQueryData as findAllPostsInBookmarksQueryData} from '#/state/queries/bookmarks/useBookmarksQuery'
1212import {findAllPostsInQueryData as findAllPostsInExploreFeedPreviewsQueryData} from '#/state/queries/explore-feed-previews'
1313import {findAllPostsInQueryData as findAllPostsInNotifsQueryData} from '#/state/queries/notifications/feed'
1414+import {findAllPostsInQueryData as findAllPostsInPostQueryData} from '#/state/queries/post'
1415import {findAllPostsInQueryData as findAllPostsInFeedQueryData} from '#/state/queries/post-feed'
1516import {findAllPostsInQueryData as findAllPostsInQuoteQueryData} from '#/state/queries/post-quotes'
1617import {findAllPostsInQueryData as findAllPostsInSearchQueryData} from '#/state/queries/search-posts'
···180181 yield post
181182 }
182183 for (let post of findAllPostsInSearchQueryData(queryClient, uri)) {
184184+ yield post
185185+ }
186186+ for (let post of findAllPostsInPostQueryData(queryClient, uri)) {
183187 yield post
184188 }
185189 for (let post of findAllPostsInQuoteQueryData(queryClient, uri)) {
+11-1
src/state/queries/post-also-liked.ts
···11import {type AppBskyFeedDefs} from '@atproto/api'
22-import {type InfiniteData, useInfiniteQuery} from '@tanstack/react-query'
22+import {
33+ type InfiniteData,
44+ useInfiniteQuery,
55+ useQueryClient,
66+} from '@tanstack/react-query'
3748import {STALE} from '#/state/queries'
99+import {precachePost} from '#/state/queries/post'
510import {useAgent} from '#/state/session'
611import {IS_WEB} from '#/env'
712···9398 opts?: {enabled?: boolean},
9499) {
95100 const agent = useAgent()
101101+ const queryClient = useQueryClient()
9610297103 return useInfiniteQuery<
98104 AlsoLikedPage,
···132138 const postsByUri = new Map(
133139 postsRes.data.posts.map(post => [post.uri, post] as const),
134140 )
141141+142142+ for (const post of postsRes.data.posts) {
143143+ precachePost(queryClient, post.uri, post)
144144+ }
135145136146 return {
137147 cursor: data.cursor,