1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
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({
onAddRecommendedFeeds,
}: {
onAddRecommendedFeeds?: () => void
}) {
const t = useTheme()
const {_} = useLingui()
const {isPending, mutateAsync: overwriteSavedFeeds} =
useOverwriteSavedFeedsMutation()
const addRecommendedFeeds = async () => {
onAddRecommendedFeeds?.()
await overwriteSavedFeeds(
RECOMMENDED_SAVED_FEEDS.map(f => ({
...f,
id: TID.nextStr(),
})),
)
}
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"
color="primary_subtle"
onPress={addRecommendedFeeds}>
<ButtonIcon icon={Plus} />
<ButtonText>{_(msg`Use recommended`)}</ButtonText>
</Button>
</View>
)
}
|