diff options
Diffstat (limited to 'src/screens/Feeds')
-rw-r--r-- | src/screens/Feeds/NoFollowingFeed.tsx | 50 | ||||
-rw-r--r-- | src/screens/Feeds/NoSavedFeedsOfAnyType.tsx | 57 |
2 files changed, 107 insertions, 0 deletions
diff --git a/src/screens/Feeds/NoFollowingFeed.tsx b/src/screens/Feeds/NoFollowingFeed.tsx new file mode 100644 index 000000000..03ced8ebd --- /dev/null +++ b/src/screens/Feeds/NoFollowingFeed.tsx @@ -0,0 +1,50 @@ +import React from 'react' +import {View} from 'react-native' +import {msg, Trans} from '@lingui/macro' +import {useLingui} from '@lingui/react' + +import {TIMELINE_SAVED_FEED} from '#/lib/constants' +import {useAddSavedFeedsMutation} from '#/state/queries/preferences' +import {atoms as a, useTheme} from '#/alf' +import {InlineLinkText} from '#/components/Link' +import {Text} from '#/components/Typography' + +export function NoFollowingFeed() { + const t = useTheme() + const {_} = useLingui() + const {mutateAsync: addSavedFeeds} = useAddSavedFeedsMutation() + + const addRecommendedFeeds = React.useCallback( + (e: any) => { + e.preventDefault() + + addSavedFeeds([ + { + ...TIMELINE_SAVED_FEED, + pinned: true, + }, + ]) + + // prevent navigation + return false + }, + [addSavedFeeds], + ) + + return ( + <View style={[a.flex_row, a.flex_wrap, a.align_center, a.py_md, a.px_lg]}> + <Text + style={[a.leading_snug, t.atoms.text_contrast_medium, {maxWidth: 310}]}> + <Trans>Looks like you're missing a following feed.</Trans>{' '} + </Text> + + <InlineLinkText + to="/" + label={_(msg`Add the default feed of only people you follow`)} + onPress={addRecommendedFeeds} + style={[a.leading_snug]}> + <Trans>Click here to add one.</Trans> + </InlineLinkText> + </View> + ) +} diff --git a/src/screens/Feeds/NoSavedFeedsOfAnyType.tsx b/src/screens/Feeds/NoSavedFeedsOfAnyType.tsx new file mode 100644 index 000000000..8f6bd9d2e --- /dev/null +++ b/src/screens/Feeds/NoSavedFeedsOfAnyType.tsx @@ -0,0 +1,57 @@ +import React from 'react' +import {View} from 'react-native' +import {TID} from '@atproto/common-web' +import {msg, Trans} from '@lingui/macro' +import {useLingui} from '@lingui/react' + +import {RECOMMENDED_SAVED_FEEDS} from '#/lib/constants' +import {useOverwriteSavedFeedsMutation} from '#/state/queries/preferences' +import {atoms as a, useTheme} from '#/alf' +import {Button, ButtonIcon, ButtonText} from '#/components/Button' +import {PlusLarge_Stroke2_Corner0_Rounded as Plus} from '#/components/icons/Plus' +import {Text} from '#/components/Typography' + +/** + * Explicitly named, since the CTA in this component will overwrite all saved + * feeds if pressed. It should only be presented to the user if they actually + * have no other feeds saved. + */ +export function NoSavedFeedsOfAnyType() { + const t = useTheme() + const {_} = useLingui() + const {isPending, mutateAsync: overwriteSavedFeeds} = + useOverwriteSavedFeedsMutation() + + const addRecommendedFeeds = React.useCallback(async () => { + await overwriteSavedFeeds( + RECOMMENDED_SAVED_FEEDS.map(f => ({ + ...f, + id: TID.nextStr(), + })), + ) + }, [overwriteSavedFeeds]) + + return ( + <View + style={[a.flex_row, a.flex_wrap, a.justify_between, a.p_xl, a.gap_md]}> + <Text + style={[a.leading_snug, t.atoms.text_contrast_medium, {maxWidth: 310}]}> + <Trans> + Looks like you haven't saved any feeds! Use our recommendations or + browse more below. + </Trans> + </Text> + + <Button + disabled={isPending} + label={_(msg`Apply default recommended feeds`)} + size="small" + variant="solid" + color="primary" + onPress={addRecommendedFeeds}> + <ButtonIcon icon={Plus} position="left" /> + <ButtonText>{_(msg`Use recommended`)}</ButtonText> + </Button> + </View> + ) +} |