about summary refs log tree commit diff
path: root/src/screens/Feeds/NoFollowingFeed.tsx
blob: 60205b8565350b84dfea1b111d028f5950559eb0 (plain) (blame)
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
import {type GestureResponderEvent, 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({onAddFeed}: {onAddFeed?: () => void}) {
  const t = useTheme()
  const {_} = useLingui()
  const {mutateAsync: addSavedFeeds} = useAddSavedFeedsMutation()

  const addRecommendedFeeds = (e: GestureResponderEvent) => {
    e.preventDefault()

    addSavedFeeds([
      {
        ...TIMELINE_SAVED_FEED,
        pinned: true,
      },
    ])

    onAddFeed?.()

    // prevent navigation
    return false as const
  }

  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]}>
        <Trans>
          Looks like you're missing a following feed.{' '}
          <InlineLinkText
            to="#"
            label={_(msg`Add the default feed of only people you follow`)}
            onPress={addRecommendedFeeds}
            style={[a.leading_snug]}>
            Click here to add one.
          </InlineLinkText>
        </Trans>
      </Text>
    </View>
  )
}