Something went wrong. Try again.
Personal iOS fork of Witchsky (itself a fork of Bluesky social-app).
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184import {type RefObject, useCallback} from 'react'import {type HostInstance, View} from 'react-native'import {Trans, useLingui} from '@lingui/react/macro'import {useQueryClient} from '@tanstack/react-query'
import {cleanError} from '#/lib/strings/errors'import {userStyle} from '#/lib/userstyles'import {unstableCacheProfileView} from '#/state/queries/profile'import { buildPostSourceKey, setUnstablePostSource,} from '#/state/unstable-post-source'import {Post} from '#/view/com/post/Post'import {PostLoadingPlaceholder} from '#/view/com/util/LoadingPlaceholder'import {atoms as a, useTheme} from '#/alf'import * as Button from '#/components/Button'import { ChevronBottom_Stroke2_Corner0_Rounded as ChevronDownIcon, ChevronTop_Stroke2_Corner0_Rounded as ChevronUpIcon,} from '#/components/icons/Chevron'import {Text} from '#/components/Typography'import {type app} from '#/lexicons'
export function ThreadAlsoLiked({ posts, visible, collapsed, isLoading: _isLoading, showLoadingState, isFetchingNextPage, error, onRetry, headerRef, onToggleCollapsed, spacerHeight, isTombstoneView,}: { posts: app.bsky.feed.defs.PostView[] visible: boolean collapsed: boolean isLoading: boolean showLoadingState: boolean isFetchingNextPage: boolean error: unknown onRetry: () => void headerRef: RefObject<HostInstance | null> onToggleCollapsed: () => void spacerHeight: number | undefined isTombstoneView: boolean}) { const {t: l} = useLingui() const t = useTheme() const queryClient = useQueryClient() const hasSection = visible const onBeforePress = useCallback( (post: app.bsky.feed.defs.PostView) => { unstableCacheProfileView(queryClient, post.author) setUnstablePostSource(buildPostSourceKey(post.uri, post.author.handle), { post: {post}, }) }, [queryClient], )
return ( <View> {hasSection && ( <View style={[ userStyle('wsky-also-liked'), a.border_t, t.atoms.border_contrast_low, ]}> <Button.Button {...{dataSet: {keyboardNavigationItem: 'true'}}} testID="alsoLikedToggle" ref={headerRef} label={ collapsed ? l`Expand also liked posts` : l`Collapse also liked posts` } onPress={onToggleCollapsed} style={[a.w_full]}> {({hovered, pressed}) => ( <View style={[ userStyle('wsky-also-liked__header'), a.w_full, a.flex_row, a.align_center, a.justify_between, a.gap_sm, a.px_lg, a.py_md, (hovered || pressed) && t.atoms.bg_contrast_25, ]}> <View style={[a.flex_1, a.gap_2xs]}> <Text style={[a.text_xl, a.font_bold]}> <Trans>Also liked</Trans> </Text> <Text style={[a.text_sm, t.atoms.text_contrast_medium]}> <Trans>Posts liked by people who liked this post</Trans> </Text> </View> {collapsed ? ( <ChevronDownIcon size="sm" style={t.atoms.text_contrast_medium} /> ) : ( <ChevronUpIcon size="sm" style={t.atoms.text_contrast_medium} /> )} </View> )} </Button.Button>
{!collapsed && ( <> {posts.map((post, index) => ( <Post key={post.uri} post={post} hideTopBorder={index === 0} onBeforePress={() => onBeforePress(post)} /> ))}
{showLoadingState && posts.length === 0 && ( <> <PostLoadingPlaceholder style={[a.border_t, t.atoms.border_contrast_low]} /> <PostLoadingPlaceholder style={[a.border_t, t.atoms.border_contrast_low]} /> </> )}
{isFetchingNextPage && ( <PostLoadingPlaceholder style={[a.border_t, t.atoms.border_contrast_low]} /> )}
{Boolean(error) && !showLoadingState && !isFetchingNextPage && ( <View style={[a.px_lg, a.pb_xl, a.gap_md]}> <Text style={[a.text_sm, t.atoms.text_contrast_medium]}> {cleanError(error)} </Text> <View style={[a.flex_row]}> <Button.Button label={l`Retry loading also liked posts`} onPress={onRetry} variant="solid" color="secondary_inverted" size="small"> <Button.ButtonText> <Trans>Retry</Trans> </Button.ButtonText> </Button.Button> </View> </View> )} </> )} </View> )}
<View style={[ a.w_full, !hasSection && !isTombstoneView && [a.border_t, t.atoms.border_contrast_low], {height: spacerHeight ?? 180}, ]} /> </View> )}