Cleanups
This commit is contained in:
@@ -6,6 +6,7 @@ import {msg, Plural, Trans} from '@lingui/macro'
|
|||||||
import {useLingui} from '@lingui/react'
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
import {useHaptics} from '#/lib/haptics'
|
import {useHaptics} from '#/lib/haptics'
|
||||||
|
import {makeProfileLink} from '#/lib/routes/links'
|
||||||
import {makeCustomFeedLink} from '#/lib/routes/links'
|
import {makeCustomFeedLink} from '#/lib/routes/links'
|
||||||
import {shareUrl} from '#/lib/sharing'
|
import {shareUrl} from '#/lib/sharing'
|
||||||
import {sanitizeHandle} from '#/lib/strings/handles'
|
import {sanitizeHandle} from '#/lib/strings/handles'
|
||||||
@@ -74,7 +75,7 @@ export function ProfileSubpageHeader({info}: {info: FeedSourceFeedInfo}) {
|
|||||||
const {mutateAsync: updateSavedFeeds, isPending: isUpdateFeedPending} =
|
const {mutateAsync: updateSavedFeeds, isPending: isUpdateFeedPending} =
|
||||||
useUpdateSavedFeedsMutation()
|
useUpdateSavedFeedsMutation()
|
||||||
|
|
||||||
const isPending =
|
const isFeedStateChangePending =
|
||||||
isAddSavedFeedPending || isRemovePending || isUpdateFeedPending
|
isAddSavedFeedPending || isRemovePending || isUpdateFeedPending
|
||||||
const savedFeedConfig = preferences?.savedFeeds?.find(
|
const savedFeedConfig = preferences?.savedFeeds?.find(
|
||||||
f => f.value === info.uri,
|
f => f.value === info.uri,
|
||||||
@@ -273,7 +274,7 @@ export function ProfileSubpageHeader({info}: {info: FeedSourceFeedInfo}) {
|
|||||||
|
|
||||||
<Menu.Outer>
|
<Menu.Outer>
|
||||||
<Menu.Item
|
<Menu.Item
|
||||||
disabled={isPending}
|
disabled={isFeedStateChangePending}
|
||||||
label={
|
label={
|
||||||
isPinned ? _(msg`Unpin from home`) : _(msg`Pin to home`)
|
isPinned ? _(msg`Unpin from home`) : _(msg`Pin to home`)
|
||||||
}
|
}
|
||||||
@@ -284,7 +285,7 @@ export function ProfileSubpageHeader({info}: {info: FeedSourceFeedInfo}) {
|
|||||||
<Menu.ItemIcon icon={isPinned ? X : Pin} position="right" />
|
<Menu.ItemIcon icon={isPinned ? X : Pin} position="right" />
|
||||||
</Menu.Item>
|
</Menu.Item>
|
||||||
<Menu.Item
|
<Menu.Item
|
||||||
disabled={isPending}
|
disabled={isFeedStateChangePending}
|
||||||
label={
|
label={
|
||||||
isSaved
|
isSaved
|
||||||
? _(msg`Remove from my feeds`)
|
? _(msg`Remove from my feeds`)
|
||||||
@@ -310,13 +311,18 @@ export function ProfileSubpageHeader({info}: {info: FeedSourceFeedInfo}) {
|
|||||||
|
|
||||||
<Dialog.Outer control={infoControl}>
|
<Dialog.Outer control={infoControl}>
|
||||||
<Dialog.Handle />
|
<Dialog.Handle />
|
||||||
<Dialog.ScrollableInner label={_(msg`Feed menu`)}>
|
<Dialog.ScrollableInner
|
||||||
|
label={_(msg`Feed menu`)}
|
||||||
|
style={[gtMobile ? {width: 'auto', minWidth: 450} : a.w_full]}>
|
||||||
<DialogInner
|
<DialogInner
|
||||||
info={info}
|
info={info}
|
||||||
likeUri={likeUri}
|
likeUri={likeUri}
|
||||||
setLikeUri={setLikeUri}
|
setLikeUri={setLikeUri}
|
||||||
likeCount={likeCount}
|
likeCount={likeCount}
|
||||||
reportDialogControl={reportDialogControl}
|
reportDialogControl={reportDialogControl}
|
||||||
|
isPinned={isPinned}
|
||||||
|
onTogglePinned={onTogglePinned}
|
||||||
|
isFeedStateChangePending={isFeedStateChangePending}
|
||||||
/>
|
/>
|
||||||
</Dialog.ScrollableInner>
|
</Dialog.ScrollableInner>
|
||||||
</Dialog.Outer>
|
</Dialog.Outer>
|
||||||
@@ -339,13 +345,20 @@ function DialogInner({
|
|||||||
setLikeUri,
|
setLikeUri,
|
||||||
likeCount,
|
likeCount,
|
||||||
reportDialogControl,
|
reportDialogControl,
|
||||||
|
isPinned,
|
||||||
|
onTogglePinned,
|
||||||
|
isFeedStateChangePending,
|
||||||
}: {
|
}: {
|
||||||
info: FeedSourceFeedInfo
|
info: FeedSourceFeedInfo
|
||||||
likeUri: string
|
likeUri: string
|
||||||
setLikeUri: (uri: string) => void
|
setLikeUri: (uri: string) => void
|
||||||
likeCount: number
|
likeCount: number
|
||||||
reportDialogControl: Dialog.DialogOuterProps['control']
|
reportDialogControl: Dialog.DialogOuterProps['control']
|
||||||
|
isPinned: boolean
|
||||||
|
onTogglePinned: () => void
|
||||||
|
isFeedStateChangePending: boolean
|
||||||
}) {
|
}) {
|
||||||
|
const control = Dialog.useDialogContext()
|
||||||
const t = useTheme()
|
const t = useTheme()
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const {hasSession} = useSession()
|
const {hasSession} = useSession()
|
||||||
@@ -405,7 +418,23 @@ function DialogInner({
|
|||||||
<Text
|
<Text
|
||||||
style={[a.text_sm, a.leading_tight, t.atoms.text_contrast_medium]}
|
style={[a.text_sm, a.leading_tight, t.atoms.text_contrast_medium]}
|
||||||
numberOfLines={1}>
|
numberOfLines={1}>
|
||||||
<Trans>By {sanitizeHandle(info.creatorHandle, '@')}</Trans>
|
<Trans>By</Trans>{' '}
|
||||||
|
<InlineLinkText
|
||||||
|
label={_(msg`View ${info.creatorHandle}'s profile`)}
|
||||||
|
to={makeProfileLink({
|
||||||
|
did: info.creatorDid,
|
||||||
|
handle: info.creatorHandle,
|
||||||
|
})}
|
||||||
|
style={[
|
||||||
|
a.text_sm,
|
||||||
|
a.leading_tight,
|
||||||
|
a.underline,
|
||||||
|
t.atoms.text_contrast_medium,
|
||||||
|
]}
|
||||||
|
numberOfLines={1}
|
||||||
|
onPress={() => control.close()}>
|
||||||
|
{sanitizeHandle(info.creatorHandle, '@')}
|
||||||
|
</InlineLinkText>
|
||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
@@ -423,26 +452,12 @@ function DialogInner({
|
|||||||
<RichText value={rt} style={[a.text_md, a.leading_snug]} />
|
<RichText value={rt} style={[a.text_md, a.leading_snug]} />
|
||||||
|
|
||||||
<View style={[a.flex_row, a.gap_sm, a.align_center]}>
|
<View style={[a.flex_row, a.gap_sm, a.align_center]}>
|
||||||
<Button
|
|
||||||
size="small"
|
|
||||||
variant="solid"
|
|
||||||
color="secondary"
|
|
||||||
shape="round"
|
|
||||||
label={isLiked ? _(msg`Unlike this feed`) : _(msg`Like this feed`)}
|
|
||||||
testID="toggleLikeBtn"
|
|
||||||
disabled={!hasSession || isLikePending || isUnlikePending}
|
|
||||||
onPress={onToggleLiked}>
|
|
||||||
{isLiked ? (
|
|
||||||
<HeartFilled size="md" fill={t.palette.negative_500} />
|
|
||||||
) : (
|
|
||||||
<Heart size="md" fill={t.atoms.text_contrast_medium.color} />
|
|
||||||
)}
|
|
||||||
</Button>
|
|
||||||
{typeof likeCount === 'number' && (
|
{typeof likeCount === 'number' && (
|
||||||
<InlineLinkText
|
<InlineLinkText
|
||||||
label={_(msg`View users who like this feed`)}
|
label={_(msg`View users who like this feed`)}
|
||||||
to={makeCustomFeedLink(info.creatorDid, feedRkey, 'liked-by')}
|
to={makeCustomFeedLink(info.creatorDid, feedRkey, 'liked-by')}
|
||||||
style={[t.atoms.text_contrast_medium, a.font_bold]}>
|
style={[a.underline, t.atoms.text_contrast_medium]}
|
||||||
|
onPress={() => control.close()}>
|
||||||
<Plural
|
<Plural
|
||||||
value={likeCount}
|
value={likeCount}
|
||||||
one="Liked by # user"
|
one="Liked by # user"
|
||||||
@@ -452,27 +467,66 @@ function DialogInner({
|
|||||||
)}
|
)}
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
<View style={[a.pt_xs, a.gap_lg]}>
|
{hasSession && (
|
||||||
<Divider />
|
<>
|
||||||
|
<View style={[a.flex_row, a.gap_sm, a.align_center, a.pt_sm]}>
|
||||||
|
<Button
|
||||||
|
disabled={isLikePending || isUnlikePending}
|
||||||
|
label={_(msg`Report feed`)}
|
||||||
|
size="small"
|
||||||
|
variant="solid"
|
||||||
|
color="secondary"
|
||||||
|
onPress={onToggleLiked}
|
||||||
|
style={[a.flex_1]}>
|
||||||
|
{isLiked ? (
|
||||||
|
<HeartFilled size="sm" fill={t.palette.negative_500} />
|
||||||
|
) : (
|
||||||
|
<ButtonIcon icon={Heart} position="left" />
|
||||||
|
)}
|
||||||
|
|
||||||
<View style={[a.flex_row, a.align_center, a.gap_sm, a.justify_between]}>
|
<ButtonText>
|
||||||
<Text style={[a.italic, t.atoms.text_contrast_medium]}>
|
{isLiked ? <Trans>Unlike</Trans> : <Trans>Like</Trans>}
|
||||||
Something wrong? Let us know.
|
</ButtonText>
|
||||||
</Text>
|
</Button>
|
||||||
|
<Button
|
||||||
|
disabled={isFeedStateChangePending}
|
||||||
|
label={_(msg`Report feed`)}
|
||||||
|
size="small"
|
||||||
|
variant="solid"
|
||||||
|
color={isPinned ? 'secondary' : 'primary'}
|
||||||
|
onPress={onTogglePinned}
|
||||||
|
style={[a.flex_1]}>
|
||||||
|
<ButtonText>
|
||||||
|
{isPinned ? <Trans>Unpin feed</Trans> : <Trans>Pin feed</Trans>}
|
||||||
|
</ButtonText>
|
||||||
|
<ButtonIcon icon={Pin} position="right" />
|
||||||
|
</Button>
|
||||||
|
</View>
|
||||||
|
|
||||||
<Button
|
<View style={[a.pt_xs, a.gap_lg]}>
|
||||||
label={_(msg`Report feed`)}
|
<Divider />
|
||||||
size="small"
|
|
||||||
variant="solid"
|
<View
|
||||||
color="secondary"
|
style={[a.flex_row, a.align_center, a.gap_sm, a.justify_between]}>
|
||||||
onPress={onPressReport}>
|
<Text style={[a.italic, t.atoms.text_contrast_medium]}>
|
||||||
<ButtonText>
|
Something wrong? Let us know.
|
||||||
<Trans>Report feed</Trans>
|
</Text>
|
||||||
</ButtonText>
|
|
||||||
<ButtonIcon icon={CircleInfo} position="right" />
|
<Button
|
||||||
</Button>
|
label={_(msg`Report feed`)}
|
||||||
</View>
|
size="small"
|
||||||
</View>
|
variant="solid"
|
||||||
|
color="secondary"
|
||||||
|
onPress={onPressReport}>
|
||||||
|
<ButtonText>
|
||||||
|
<Trans>Report feed</Trans>
|
||||||
|
</ButtonText>
|
||||||
|
<ButtonIcon icon={CircleInfo} position="right" />
|
||||||
|
</Button>
|
||||||
|
</View>
|
||||||
|
</View>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user