Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: make Also liked posts show loaded when opened

+47 -1
+43 -1
src/state/queries/post-also-liked.ts
··· 1 - import {type AppBskyFeedDefs} from '@atproto/api' 1 + import {type AppBskyFeedDefs, AtUri} from '@atproto/api' 2 2 import { 3 3 type InfiniteData, 4 + type QueryClient, 4 5 useInfiniteQuery, 5 6 useQueryClient, 6 7 } from '@tanstack/react-query' ··· 8 9 import {STALE} from '#/state/queries' 9 10 import {precachePost} from '#/state/queries/post' 10 11 import {useAgent} from '#/state/session' 12 + import {embedViewRecordToPostView, getEmbeddedPost} from './util' 11 13 12 14 const ALSO_LIKED_URL = 'https://foryou.club/also-liked' 13 15 const ALSO_LIKED_PAGE_SIZE = 10 ··· 123 125 }, 124 126 }) 125 127 } 128 + 129 + export function* findAllPostsInQueryData( 130 + queryClient: QueryClient, 131 + uri: string, 132 + ): Generator<AppBskyFeedDefs.PostView, void> { 133 + const atUri = new AtUri(uri) 134 + const queryDatas = queryClient.getQueriesData<InfiniteData<AlsoLikedPage>>({ 135 + queryKey: [RQKEY_ROOT], 136 + }) 137 + 138 + for (const [_queryKey, queryData] of queryDatas) { 139 + if (!queryData?.pages) { 140 + continue 141 + } 142 + 143 + for (const page of queryData.pages) { 144 + for (const post of page.posts) { 145 + if (uriMatches(atUri, post)) { 146 + yield post 147 + } 148 + 149 + const quotedPost = getEmbeddedPost(post.embed) 150 + if (quotedPost && uriMatches(atUri, quotedPost)) { 151 + yield embedViewRecordToPostView(quotedPost) 152 + } 153 + } 154 + } 155 + } 156 + } 157 + 158 + function uriMatches( 159 + atUri: AtUri, 160 + record: {uri: string; author: AppBskyFeedDefs.PostView['author']}, 161 + ) { 162 + if (atUri.host.startsWith('did:')) { 163 + return atUri.href === record.uri 164 + } 165 + 166 + return atUri.host === record.author.handle && record.uri.endsWith(atUri.rkey) 167 + }
+4
src/state/queries/usePostThread/queryCache.ts
··· 18 18 import {findAllPostsInQueryData as findAllPostsInExploreFeedPreviewsQueryData} from '#/state/queries/explore-feed-previews' 19 19 import {findAllPostsInQueryData as findAllPostsInNotifsQueryData} from '#/state/queries/notifications/feed' 20 20 import {findAllPostsInQueryData as findAllPostsInPostQueryData} from '#/state/queries/post' 21 + import {findAllPostsInQueryData as findAllPostsInAlsoLikedQueryData} from '#/state/queries/post-also-liked' 21 22 import {findAllPostsInQueryData as findAllPostsInFeedQueryData} from '#/state/queries/post-feed' 22 23 import {findAllPostsInQueryData as findAllPostsInQuoteQueryData} from '#/state/queries/post-quotes' 23 24 import {findAllPostsInQueryData as findAllPostsInSearchQueryData} from '#/state/queries/search-posts' ··· 261 262 yield postViewToThreadPlaceholder(post) 262 263 } 263 264 for (let post of findAllPostsInSearchQueryData(queryClient, uri)) { 265 + yield postViewToThreadPlaceholder(post) 266 + } 267 + for (let post of findAllPostsInAlsoLikedQueryData(queryClient, uri)) { 264 268 yield postViewToThreadPlaceholder(post) 265 269 } 266 270 for (let post of findAllPostsInPostQueryData(queryClient, uri)) {