From bf935e55da8ed0f1569bdeb69f5c3999cff0e945 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Tue, 25 Jun 2024 18:36:35 -0500 Subject: [PATCH] Make Action comp easier to use, clarify list purpose --- src/components/FeedCard.tsx | 21 +++++++++++---------- src/components/ListCard.tsx | 17 +++++++++++------ 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/src/components/FeedCard.tsx b/src/components/FeedCard.tsx index 3f507726c1..5cf2ba96a4 100644 --- a/src/components/FeedCard.tsx +++ b/src/components/FeedCard.tsx @@ -3,6 +3,7 @@ import {GestureResponderEvent, View} from 'react-native' import { AppBskyActorDefs, AppBskyFeedDefs, + AppBskyGraphDefs, AtUri, RichText as RichTextApi, } from '@atproto/api' @@ -44,7 +45,7 @@ export function Default(props: Props) {
- +
@@ -190,27 +191,23 @@ export function Likes({count}: {count: number}) { } export function Action({ - uri, + view, pin, - type, }: { - uri: string + view: AppBskyFeedDefs.GeneratorView | AppBskyGraphDefs.ListView pin?: boolean - type: 'feed' | 'list' }) { const {hasSession} = useSession() if (!hasSession) return null - return + return } function ActionInner({ - uri, + view, pin, - type, }: { - uri: string + view: AppBskyFeedDefs.GeneratorView | AppBskyGraphDefs.ListView pin?: boolean - type: 'feed' | 'list' }) { const {_} = useLingui() const {data: preferences} = usePreferencesQuery() @@ -218,6 +215,10 @@ function ActionInner({ useAddSavedFeedsMutation() const {isPending: isRemovePending, mutateAsync: removeFeed} = useRemoveFeedMutation() + + const uri = view.uri + const type = view.uri.includes('app.bsky.feed.generator') ? 'feed' : 'list' + const savedFeedConfig = React.useMemo(() => { return preferences?.savedFeeds?.find(feed => feed.value === uri) }, [preferences?.savedFeeds, uri]) diff --git a/src/components/ListCard.tsx b/src/components/ListCard.tsx index 737281ca2c..c214db6bd7 100644 --- a/src/components/ListCard.tsx +++ b/src/components/ListCard.tsx @@ -27,6 +27,9 @@ export { TitleAndBylinePlaceholder, } from '#/components/FeedCard' +const CURATELIST = 'app.bsky.graph.defs#curatelist' +const MODLIST = 'app.bsky.graph.defs#modlist' + type Props = { view: AppBskyGraphDefs.ListView showPinButton?: boolean @@ -44,7 +47,9 @@ export function Default(props: Props) { creator={view.creator} purpose={view.purpose} /> - {showPinButton && } + {showPinButton && view.purpose === CURATELIST && ( + + )} @@ -77,11 +82,11 @@ export function Link({ export function TitleAndByline({ title, creator, - purpose, + purpose = CURATELIST, }: { title: string creator?: AppBskyActorDefs.ProfileViewBasic - purpose: AppBskyGraphDefs.ListView['purpose'] + purpose?: AppBskyGraphDefs.ListView['purpose'] }) { const t = useTheme() @@ -94,12 +99,12 @@ export function TitleAndByline({ - {purpose === 'app.bsky.graph.defs#curatelist' ? ( - List by {sanitizeHandle(creator.handle, '@')} - ) : ( + {purpose === MODLIST ? ( Moderation list by {sanitizeHandle(creator.handle, '@')} + ) : ( + List by {sanitizeHandle(creator.handle, '@')} )} )}