Make Action comp easier to use, clarify list purpose
This commit is contained in:
+11
-10
@@ -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) {
|
||||
<Header>
|
||||
<Avatar src={view.avatar} />
|
||||
<TitleAndByline title={view.displayName} creator={view.creator} />
|
||||
<Action uri={view.uri} pin type="feed" />
|
||||
<Action view={view} pin />
|
||||
</Header>
|
||||
<Description description={view.description} />
|
||||
<Likes count={view.likeCount || 0} />
|
||||
@@ -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 <ActionInner uri={uri} pin={pin} type={type} />
|
||||
return <ActionInner view={view} pin={pin} />
|
||||
}
|
||||
|
||||
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])
|
||||
|
||||
@@ -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 && <Action uri={view.uri} pin type="list" />}
|
||||
{showPinButton && view.purpose === CURATELIST && (
|
||||
<Action view={view} pin />
|
||||
)}
|
||||
</Header>
|
||||
<Description description={view.description} />
|
||||
</Outer>
|
||||
@@ -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({
|
||||
<Text
|
||||
style={[a.leading_snug, t.atoms.text_contrast_medium]}
|
||||
numberOfLines={1}>
|
||||
{purpose === 'app.bsky.graph.defs#curatelist' ? (
|
||||
<Trans>List by {sanitizeHandle(creator.handle, '@')}</Trans>
|
||||
) : (
|
||||
{purpose === MODLIST ? (
|
||||
<Trans>
|
||||
Moderation list by {sanitizeHandle(creator.handle, '@')}
|
||||
</Trans>
|
||||
) : (
|
||||
<Trans>List by {sanitizeHandle(creator.handle, '@')}</Trans>
|
||||
)}
|
||||
</Text>
|
||||
)}
|
||||
|
||||
Reference in New Issue
Block a user