Handle no following feed
This commit is contained in:
@@ -0,0 +1,48 @@
|
|||||||
|
import React from 'react'
|
||||||
|
import {View} from 'react-native'
|
||||||
|
import {msg, Trans} from '@lingui/macro'
|
||||||
|
import {useLingui} from '@lingui/react'
|
||||||
|
|
||||||
|
import {useAddSavedFeedMutation} 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: addSavedFeed} = useAddSavedFeedMutation()
|
||||||
|
|
||||||
|
const addRecommendedFeeds = React.useCallback(
|
||||||
|
(e: any) => {
|
||||||
|
e.preventDefault()
|
||||||
|
|
||||||
|
addSavedFeed({
|
||||||
|
type: 'timeline',
|
||||||
|
value: 'home',
|
||||||
|
pinned: true,
|
||||||
|
})
|
||||||
|
|
||||||
|
// prevent navigation
|
||||||
|
return false
|
||||||
|
},
|
||||||
|
[addSavedFeed],
|
||||||
|
)
|
||||||
|
|
||||||
|
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>
|
||||||
|
)
|
||||||
|
}
|
||||||
@@ -45,6 +45,7 @@ import {
|
|||||||
import {Text} from 'view/com/util/text/Text'
|
import {Text} from 'view/com/util/text/Text'
|
||||||
import {UserAvatar} from 'view/com/util/UserAvatar'
|
import {UserAvatar} from 'view/com/util/UserAvatar'
|
||||||
import {ViewHeader} from 'view/com/util/ViewHeader'
|
import {ViewHeader} from 'view/com/util/ViewHeader'
|
||||||
|
import {NoFollowingFeed} from '#/screens/Feeds/NoFollowingFeed'
|
||||||
import {NoSavedFeeds} from '#/screens/Feeds/NoSavedFeeds'
|
import {NoSavedFeeds} from '#/screens/Feeds/NoSavedFeeds'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
import {IconCircle} from '#/components/IconCircle'
|
import {IconCircle} from '#/components/IconCircle'
|
||||||
@@ -104,6 +105,10 @@ type FlatlistSlice =
|
|||||||
type: 'popularFeedsLoadingMore'
|
type: 'popularFeedsLoadingMore'
|
||||||
key: string
|
key: string
|
||||||
}
|
}
|
||||||
|
| {
|
||||||
|
type: 'noFollowingFeed'
|
||||||
|
key: string
|
||||||
|
}
|
||||||
|
|
||||||
// HACK
|
// HACK
|
||||||
// the protocol doesn't yet tell us which feeds are personalized
|
// the protocol doesn't yet tell us which feeds are personalized
|
||||||
@@ -241,6 +246,10 @@ export function FeedsScreen(_props: Props) {
|
|||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
if (preferences.savedFeeds?.length) {
|
if (preferences.savedFeeds?.length) {
|
||||||
|
const noFollowingFeed = preferences.savedFeeds.every(
|
||||||
|
f => f.type !== 'timeline',
|
||||||
|
)
|
||||||
|
|
||||||
slices = slices.concat(
|
slices = slices.concat(
|
||||||
preferences.savedFeeds
|
preferences.savedFeeds
|
||||||
.filter(f => {
|
.filter(f => {
|
||||||
@@ -265,6 +274,13 @@ export function FeedsScreen(_props: Props) {
|
|||||||
savedFeedConfig: feed,
|
savedFeedConfig: feed,
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (noFollowingFeed) {
|
||||||
|
slices.push({
|
||||||
|
key: 'noFollowingFeed',
|
||||||
|
type: 'noFollowingFeed',
|
||||||
|
})
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
slices.push({
|
slices.push({
|
||||||
key: 'savedFeedNoResults',
|
key: 'savedFeedNoResults',
|
||||||
@@ -540,6 +556,18 @@ export function FeedsScreen(_props: Props) {
|
|||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
)
|
)
|
||||||
|
} else if (item.type === 'noFollowingFeed') {
|
||||||
|
return (
|
||||||
|
<View
|
||||||
|
style={[
|
||||||
|
pal.border,
|
||||||
|
{
|
||||||
|
borderBottomWidth: 1,
|
||||||
|
},
|
||||||
|
]}>
|
||||||
|
<NoFollowingFeed />
|
||||||
|
</View>
|
||||||
|
)
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import {Text} from 'view/com/util/text/Text'
|
|||||||
import * as Toast from 'view/com/util/Toast'
|
import * as Toast from 'view/com/util/Toast'
|
||||||
import {ViewHeader} from 'view/com/util/ViewHeader'
|
import {ViewHeader} from 'view/com/util/ViewHeader'
|
||||||
import {CenteredView, ScrollView} from 'view/com/util/Views'
|
import {CenteredView, ScrollView} from 'view/com/util/Views'
|
||||||
|
import {NoFollowingFeed} from '#/screens/Feeds/NoFollowingFeed'
|
||||||
import {NoSavedFeeds} from '#/screens/Feeds/NoSavedFeeds'
|
import {NoSavedFeeds} from '#/screens/Feeds/NoSavedFeeds'
|
||||||
import {atoms as a, useTheme} from '#/alf'
|
import {atoms as a, useTheme} from '#/alf'
|
||||||
import {FilterTimeline_Stroke2_Corner0_Rounded as FilterTimeline} from '#/components/icons/FilterTimeline'
|
import {FilterTimeline_Stroke2_Corner0_Rounded as FilterTimeline} from '#/components/icons/FilterTimeline'
|
||||||
@@ -71,6 +72,8 @@ export function SavedFeeds({}: Props) {
|
|||||||
const pinnedFeeds = currentFeeds.filter(f => f.pinned)
|
const pinnedFeeds = currentFeeds.filter(f => f.pinned)
|
||||||
const unpinnedFeeds = currentFeeds.filter(f => !f.pinned)
|
const unpinnedFeeds = currentFeeds.filter(f => !f.pinned)
|
||||||
const noSavedFeeds = pinnedFeeds.length + unpinnedFeeds.length === 0
|
const noSavedFeeds = pinnedFeeds.length + unpinnedFeeds.length === 0
|
||||||
|
const noFollowingFeed =
|
||||||
|
currentFeeds.every(f => f.type !== 'timeline') && !noSavedFeeds
|
||||||
|
|
||||||
useFocusEffect(
|
useFocusEffect(
|
||||||
React.useCallback(() => {
|
React.useCallback(() => {
|
||||||
@@ -129,6 +132,13 @@ export function SavedFeeds({}: Props) {
|
|||||||
) : (
|
) : (
|
||||||
<ActivityIndicator style={{marginTop: 20}} />
|
<ActivityIndicator style={{marginTop: 20}} />
|
||||||
)}
|
)}
|
||||||
|
|
||||||
|
{noFollowingFeed && (
|
||||||
|
<View style={[pal.border, {borderBottomWidth: 1}]}>
|
||||||
|
<NoFollowingFeed />
|
||||||
|
</View>
|
||||||
|
)}
|
||||||
|
|
||||||
<View style={[pal.text, pal.border, styles.title]}>
|
<View style={[pal.text, pal.border, styles.title]}>
|
||||||
<Text type="title" style={pal.text}>
|
<Text type="title" style={pal.text}>
|
||||||
<Trans>Saved Feeds</Trans>
|
<Trans>Saved Feeds</Trans>
|
||||||
|
|||||||
Reference in New Issue
Block a user