Bluesky app fork with some witchin' additions 💫 witchsky.app
bluesky fork client
117
fork

Configure Feed

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

fix: make 'Also liked' act more like a regular feed

oh no it's so long now

+51 -35
+39 -6
src/screens/PostThread/components/ThreadAlsoLiked.tsx
··· 1 + import {useCallback} from 'react' 1 2 import {View} from 'react-native' 2 3 import {type AppBskyFeedDefs} from '@atproto/api' 3 4 import {Trans, useLingui} from '@lingui/react/macro' 5 + import {useQueryClient} from '@tanstack/react-query' 4 6 5 7 import {cleanError} from '#/lib/strings/errors' 8 + import {unstableCacheProfileView} from '#/state/queries/profile' 9 + import { 10 + buildPostSourceKey, 11 + setUnstablePostSource, 12 + } from '#/state/unstable-post-source' 6 13 import {Post} from '#/view/com/post/Post' 14 + import {PostLoadingPlaceholder} from '#/view/com/util/LoadingPlaceholder' 7 15 import {atoms as a, useTheme} from '#/alf' 8 16 import {Button, ButtonText} from '#/components/Button' 9 - import {Loader} from '#/components/Loader' 10 17 import {Text} from '#/components/Typography' 11 18 12 19 export function ThreadAlsoLiked({ ··· 30 37 }) { 31 38 const {t: l} = useLingui() 32 39 const t = useTheme() 40 + const queryClient = useQueryClient() 33 41 const hasSection = 34 42 enabled && (posts.length > 0 || isLoading || Boolean(error)) 43 + const onBeforePress = useCallback( 44 + (post: AppBskyFeedDefs.PostView) => { 45 + unstableCacheProfileView(queryClient, post.author) 46 + setUnstablePostSource(buildPostSourceKey(post.uri, post.author.handle), { 47 + post: {post}, 48 + }) 49 + }, 50 + [queryClient], 51 + ) 35 52 36 53 return ( 37 54 <View> ··· 47 64 </View> 48 65 49 66 {posts.map((post, index) => ( 50 - <Post key={post.uri} post={post} hideTopBorder={index === 0} /> 67 + <Post 68 + key={post.uri} 69 + post={post} 70 + hideTopBorder={index === 0} 71 + onBeforePress={() => onBeforePress(post)} 72 + /> 51 73 ))} 52 74 53 - {(isLoading || isFetchingNextPage) && ( 54 - <View style={[a.align_center, a.py_xl]}> 55 - <Loader size="xl" /> 56 - </View> 75 + {isLoading && posts.length === 0 && ( 76 + <> 77 + <PostLoadingPlaceholder 78 + style={[a.border_t, t.atoms.border_contrast_low]} 79 + /> 80 + <PostLoadingPlaceholder 81 + style={[a.border_t, t.atoms.border_contrast_low]} 82 + /> 83 + </> 84 + )} 85 + 86 + {isFetchingNextPage && ( 87 + <PostLoadingPlaceholder 88 + style={[a.border_t, t.atoms.border_contrast_low]} 89 + /> 57 90 )} 58 91 59 92 {Boolean(error) && !isLoading && !isFetchingNextPage && (
+8 -29
src/screens/PostThread/index.tsx
··· 154 154 const alsoLikedAnchorUri = 155 155 anchor?.type === 'threadPost' && isRoot ? anchor.value.post.uri : undefined 156 156 const [deferParents, setDeferParents] = useState(true) 157 - const [alsoLikedReady, setAlsoLikedReady] = useState(false) 158 - useEffect(() => { 159 - const shouldEnable = 160 - Boolean(alsoLikedAnchorUri) && 161 - alsoLikedFeedEnabled && 162 - !thread.state.isPlaceholderData && 163 - !deferParents 164 - 165 - if (!shouldEnable) { 166 - setAlsoLikedReady(false) 167 - return 168 - } 169 - 170 - const timeout = setTimeout(() => { 171 - startTransition(() => { 172 - setAlsoLikedReady(true) 173 - }) 174 - }, 0) 175 - 176 - return () => clearTimeout(timeout) 177 - }, [ 178 - alsoLikedAnchorUri, 179 - alsoLikedFeedEnabled, 180 - deferParents, 181 - thread.state.isPlaceholderData, 182 - ]) 157 + const alsoLikedEnabled = 158 + Boolean(alsoLikedAnchorUri) && 159 + alsoLikedFeedEnabled && 160 + !thread.state.isPlaceholderData && 161 + !deferParents 183 162 const alsoLiked = usePostAlsoLikedQuery(alsoLikedAnchorUri, { 184 - enabled: alsoLikedReady, 163 + enabled: alsoLikedEnabled, 185 164 }) 186 165 const alsoLikedPosts = useMemo(() => { 187 166 const seen = new Set<string>() ··· 381 360 } 382 361 if ( 383 362 alsoLikedAnchorUri && 384 - alsoLikedReady && 363 + alsoLikedEnabled && 385 364 !alsoLiked.isLoading && 386 365 !alsoLiked.isFetchingNextPage && 387 366 alsoLiked.hasNextPage ··· 659 638 ListFooterComponent={ 660 639 <ThreadAlsoLiked 661 640 posts={alsoLikedPosts} 662 - enabled={alsoLikedReady} 641 + enabled={alsoLikedEnabled} 663 642 isLoading={alsoLiked.isLoading} 664 643 isFetchingNextPage={alsoLiked.isFetchingNextPage} 665 644 error={alsoLiked.error}
+4
src/state/queries/usePostThread/queryCache.ts
··· 17 17 import {findAllPostsInQueryData as findAllPostsInBookmarksQueryData} from '#/state/queries/bookmarks/useBookmarksQuery' 18 18 import {findAllPostsInQueryData as findAllPostsInExploreFeedPreviewsQueryData} from '#/state/queries/explore-feed-previews' 19 19 import {findAllPostsInQueryData as findAllPostsInNotifsQueryData} from '#/state/queries/notifications/feed' 20 + import {findAllPostsInQueryData as findAllPostsInPostQueryData} from '#/state/queries/post' 20 21 import {findAllPostsInQueryData as findAllPostsInFeedQueryData} from '#/state/queries/post-feed' 21 22 import {findAllPostsInQueryData as findAllPostsInQuoteQueryData} from '#/state/queries/post-quotes' 22 23 import {findAllPostsInQueryData as findAllPostsInSearchQueryData} from '#/state/queries/search-posts' ··· 260 261 yield postViewToThreadPlaceholder(post) 261 262 } 262 263 for (let post of findAllPostsInSearchQueryData(queryClient, uri)) { 264 + yield postViewToThreadPlaceholder(post) 265 + } 266 + for (let post of findAllPostsInPostQueryData(queryClient, uri)) { 263 267 yield postViewToThreadPlaceholder(post) 264 268 } 265 269 for (let post of findAllPostsInBookmarksQueryData(queryClient, uri)) {