diff options
author | Eric Bailey <git@esb.lol> | 2025-04-15 08:13:20 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-04-15 06:13:20 -0700 |
commit | f46336e34142e7f46bb1395f727e303e37b15d41 (patch) | |
tree | dac04a4abd8d100dc9c0d5c65ab7f75f1d3280eb /src/components/LikesDialog.tsx | |
parent | 32c2b69b848050975b698067383dd24f2754cab2 (diff) | |
download | voidsky-f46336e34142e7f46bb1395f727e303e37b15d41.tar.zst |
Replace old ProfileCard with new (#8195)
* Replace usages of old ProfileCard * Replace Pills with Labels component * Replace impl of ProfileCardWithFollowButton * Remove never-used LikesDialog * Handle missing mod opts * Add missing profile hover * use modern button in listmembers * remove follow button from muted accounts list --------- Co-authored-by: Samuel Newman <mozzius@protonmail.com>
Diffstat (limited to 'src/components/LikesDialog.tsx')
-rw-r--r-- | src/components/LikesDialog.tsx | 129 |
1 files changed, 0 insertions, 129 deletions
diff --git a/src/components/LikesDialog.tsx b/src/components/LikesDialog.tsx deleted file mode 100644 index cb000b433..000000000 --- a/src/components/LikesDialog.tsx +++ /dev/null @@ -1,129 +0,0 @@ -import {useCallback, useMemo} from 'react' -import {ActivityIndicator, FlatList, View} from 'react-native' -import {AppBskyFeedGetLikes as GetLikes} from '@atproto/api' -import {msg, Trans} from '@lingui/macro' -import {useLingui} from '@lingui/react' - -import {cleanError} from '#/lib/strings/errors' -import {logger} from '#/logger' -import {useLikedByQuery} from '#/state/queries/post-liked-by' -import {useResolveUriQuery} from '#/state/queries/resolve-uri' -import {ProfileCardWithFollowBtn} from '#/view/com/profile/ProfileCard' -import {ErrorMessage} from '#/view/com/util/error/ErrorMessage' -import {atoms as a, useTheme} from '#/alf' -import * as Dialog from '#/components/Dialog' -import {Loader} from '#/components/Loader' -import {Text} from '#/components/Typography' - -interface LikesDialogProps { - control: Dialog.DialogOuterProps['control'] - uri: string -} - -export function LikesDialog(props: LikesDialogProps) { - return ( - <Dialog.Outer control={props.control}> - <Dialog.Handle /> - <LikesDialogInner {...props} /> - </Dialog.Outer> - ) -} - -export function LikesDialogInner({control, uri}: LikesDialogProps) { - const {_} = useLingui() - const t = useTheme() - - const { - data: resolvedUri, - error: resolveError, - isFetched: hasFetchedResolvedUri, - } = useResolveUriQuery(uri) - const { - data, - isFetching: isFetchingLikedBy, - isFetched: hasFetchedLikedBy, - isFetchingNextPage, - hasNextPage, - fetchNextPage, - isError, - error: likedByError, - } = useLikedByQuery(resolvedUri?.uri) - - const isLoading = !hasFetchedResolvedUri || !hasFetchedLikedBy - const likes = useMemo(() => { - if (data?.pages) { - return data.pages.flatMap(page => page.likes) - } - return [] - }, [data]) - - const onEndReached = useCallback(async () => { - if (isFetchingLikedBy || !hasNextPage || isError) return - try { - await fetchNextPage() - } catch (err) { - logger.error('Failed to load more likes', {message: err}) - } - }, [isFetchingLikedBy, hasNextPage, isError, fetchNextPage]) - - const renderItem = useCallback( - ({item}: {item: GetLikes.Like}) => { - return ( - <ProfileCardWithFollowBtn - key={item.actor.did} - profile={item.actor} - onPress={() => control.close()} - /> - ) - }, - [control], - ) - - return ( - <Dialog.Inner label={_(msg`Users that have liked this content or profile`)}> - <Text style={[a.text_2xl, a.font_bold, a.leading_tight, a.pb_lg]}> - <Trans>Liked by</Trans> - </Text> - - {isLoading ? ( - <View style={{minHeight: 300}}> - <Loader size="xl" /> - </View> - ) : resolveError || likedByError || !data ? ( - <ErrorMessage message={cleanError(resolveError || likedByError)} /> - ) : likes.length === 0 ? ( - <View style={[t.atoms.bg_contrast_50, a.px_md, a.py_xl, a.rounded_md]}> - <Text style={[a.text_center]}> - <Trans> - Nobody has liked this yet. Maybe you should be the first! - </Trans> - </Text> - </View> - ) : ( - <FlatList - data={likes} - keyExtractor={item => item.actor.did} - onEndReached={onEndReached} - renderItem={renderItem} - initialNumToRender={15} - ListFooterComponent={ - <ListFooterComponent isFetching={isFetchingNextPage} /> - } - /> - )} - - <Dialog.Close /> - </Dialog.Inner> - ) -} - -function ListFooterComponent({isFetching}: {isFetching: boolean}) { - if (isFetching) { - return ( - <View style={a.pt_lg}> - <ActivityIndicator /> - </View> - ) - } - return null -} |