parent
8da10a5edc
commit
3de1d556a9
|
@ -34,6 +34,7 @@ import {
|
||||||
} from '#/state/queries/feed'
|
} from '#/state/queries/feed'
|
||||||
import {cleanError} from 'lib/strings/errors'
|
import {cleanError} from 'lib/strings/errors'
|
||||||
import {useComposerControls} from '#/state/shell/composer'
|
import {useComposerControls} from '#/state/shell/composer'
|
||||||
|
import {useSession} from '#/state/session'
|
||||||
|
|
||||||
type Props = NativeStackScreenProps<FeedsTabNavigatorParams, 'Feeds'>
|
type Props = NativeStackScreenProps<FeedsTabNavigatorParams, 'Feeds'>
|
||||||
|
|
||||||
|
@ -117,6 +118,7 @@ export const FeedsScreen = withAuthRequired(
|
||||||
isPending: isSearchPending,
|
isPending: isSearchPending,
|
||||||
error: searchError,
|
error: searchError,
|
||||||
} = useSearchPopularFeedsMutation()
|
} = useSearchPopularFeedsMutation()
|
||||||
|
const {hasSession} = useSession()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A search query is present. We may not have search results yet.
|
* A search query is present. We may not have search results yet.
|
||||||
|
@ -180,50 +182,52 @@ export const FeedsScreen = withAuthRequired(
|
||||||
const items = React.useMemo(() => {
|
const items = React.useMemo(() => {
|
||||||
let slices: FlatlistSlice[] = []
|
let slices: FlatlistSlice[] = []
|
||||||
|
|
||||||
slices.push({
|
if (hasSession) {
|
||||||
key: 'savedFeedsHeader',
|
|
||||||
type: 'savedFeedsHeader',
|
|
||||||
})
|
|
||||||
|
|
||||||
if (preferencesError) {
|
|
||||||
slices.push({
|
slices.push({
|
||||||
key: 'savedFeedsError',
|
key: 'savedFeedsHeader',
|
||||||
type: 'error',
|
type: 'savedFeedsHeader',
|
||||||
error: cleanError(preferencesError.toString()),
|
|
||||||
})
|
})
|
||||||
} else {
|
|
||||||
if (isPreferencesLoading || !preferences?.feeds?.saved) {
|
if (preferencesError) {
|
||||||
slices.push({
|
slices.push({
|
||||||
key: 'savedFeedsLoading',
|
key: 'savedFeedsError',
|
||||||
type: 'savedFeedsLoading',
|
type: 'error',
|
||||||
// pendingItems: this.rootStore.preferences.savedFeeds.length || 3,
|
error: cleanError(preferencesError.toString()),
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
if (preferences?.feeds?.saved.length === 0) {
|
if (isPreferencesLoading || !preferences?.feeds?.saved) {
|
||||||
slices.push({
|
slices.push({
|
||||||
key: 'savedFeedNoResults',
|
key: 'savedFeedsLoading',
|
||||||
type: 'savedFeedNoResults',
|
type: 'savedFeedsLoading',
|
||||||
|
// pendingItems: this.rootStore.preferences.savedFeeds.length || 3,
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
const {saved, pinned} = preferences.feeds
|
if (preferences?.feeds?.saved.length === 0) {
|
||||||
|
slices.push({
|
||||||
|
key: 'savedFeedNoResults',
|
||||||
|
type: 'savedFeedNoResults',
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
const {saved, pinned} = preferences.feeds
|
||||||
|
|
||||||
slices = slices.concat(
|
slices = slices.concat(
|
||||||
pinned.map(uri => ({
|
pinned.map(uri => ({
|
||||||
key: `savedFeed:${uri}`,
|
|
||||||
type: 'savedFeed',
|
|
||||||
feedUri: uri,
|
|
||||||
})),
|
|
||||||
)
|
|
||||||
|
|
||||||
slices = slices.concat(
|
|
||||||
saved
|
|
||||||
.filter(uri => !pinned.includes(uri))
|
|
||||||
.map(uri => ({
|
|
||||||
key: `savedFeed:${uri}`,
|
key: `savedFeed:${uri}`,
|
||||||
type: 'savedFeed',
|
type: 'savedFeed',
|
||||||
feedUri: uri,
|
feedUri: uri,
|
||||||
})),
|
})),
|
||||||
)
|
)
|
||||||
|
|
||||||
|
slices = slices.concat(
|
||||||
|
saved
|
||||||
|
.filter(uri => !pinned.includes(uri))
|
||||||
|
.map(uri => ({
|
||||||
|
key: `savedFeed:${uri}`,
|
||||||
|
type: 'savedFeed',
|
||||||
|
feedUri: uri,
|
||||||
|
})),
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -307,6 +311,7 @@ export const FeedsScreen = withAuthRequired(
|
||||||
|
|
||||||
return slices
|
return slices
|
||||||
}, [
|
}, [
|
||||||
|
hasSession,
|
||||||
preferences,
|
preferences,
|
||||||
isPreferencesLoading,
|
isPreferencesLoading,
|
||||||
preferencesError,
|
preferencesError,
|
||||||
|
@ -393,7 +398,8 @@ export const FeedsScreen = withAuthRequired(
|
||||||
pal.view,
|
pal.view,
|
||||||
styles.header,
|
styles.header,
|
||||||
{
|
{
|
||||||
marginTop: 16,
|
// This is first in the flatlist without a session -esb
|
||||||
|
marginTop: hasSession ? 16 : 0,
|
||||||
paddingLeft: isMobile ? 12 : undefined,
|
paddingLeft: isMobile ? 12 : undefined,
|
||||||
paddingRight: 10,
|
paddingRight: 10,
|
||||||
paddingBottom: isMobile ? 6 : undefined,
|
paddingBottom: isMobile ? 6 : undefined,
|
||||||
|
@ -432,7 +438,7 @@ export const FeedsScreen = withAuthRequired(
|
||||||
return (
|
return (
|
||||||
<FeedSourceCard
|
<FeedSourceCard
|
||||||
feedUri={item.feedUri}
|
feedUri={item.feedUri}
|
||||||
showSaveBtn
|
showSaveBtn={hasSession}
|
||||||
showDescription
|
showDescription
|
||||||
showLikes
|
showLikes
|
||||||
/>
|
/>
|
||||||
|
@ -455,6 +461,7 @@ export const FeedsScreen = withAuthRequired(
|
||||||
},
|
},
|
||||||
[
|
[
|
||||||
_,
|
_,
|
||||||
|
hasSession,
|
||||||
isMobile,
|
isMobile,
|
||||||
pal,
|
pal,
|
||||||
query,
|
query,
|
||||||
|
|
|
@ -165,7 +165,7 @@ export function ProfileFeedScreenInner({
|
||||||
}) {
|
}) {
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const pal = usePalette('default')
|
const pal = usePalette('default')
|
||||||
const {currentAccount} = useSession()
|
const {hasSession, currentAccount} = useSession()
|
||||||
const {openModal} = useModalControls()
|
const {openModal} = useModalControls()
|
||||||
const {openComposer} = useComposerControls()
|
const {openComposer} = useComposerControls()
|
||||||
const {track} = useAnalytics()
|
const {track} = useAnalytics()
|
||||||
|
@ -270,7 +270,7 @@ export function ProfileFeedScreenInner({
|
||||||
|
|
||||||
const dropdownItems: DropdownItem[] = React.useMemo(() => {
|
const dropdownItems: DropdownItem[] = React.useMemo(() => {
|
||||||
return [
|
return [
|
||||||
{
|
hasSession && {
|
||||||
testID: 'feedHeaderDropdownToggleSavedBtn',
|
testID: 'feedHeaderDropdownToggleSavedBtn',
|
||||||
label: isSaved ? _(msg`Remove from my feeds`) : _(msg`Add to my feeds`),
|
label: isSaved ? _(msg`Remove from my feeds`) : _(msg`Add to my feeds`),
|
||||||
onPress: isSavePending || isRemovePending ? undefined : onToggleSaved,
|
onPress: isSavePending || isRemovePending ? undefined : onToggleSaved,
|
||||||
|
@ -290,7 +290,7 @@ export function ProfileFeedScreenInner({
|
||||||
web: 'plus',
|
web: 'plus',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
hasSession && {
|
||||||
testID: 'feedHeaderDropdownReportBtn',
|
testID: 'feedHeaderDropdownReportBtn',
|
||||||
label: _(msg`Report feed`),
|
label: _(msg`Report feed`),
|
||||||
onPress: onPressReport,
|
onPress: onPressReport,
|
||||||
|
@ -314,8 +314,9 @@ export function ProfileFeedScreenInner({
|
||||||
web: 'share',
|
web: 'share',
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
] as DropdownItem[]
|
].filter(Boolean) as DropdownItem[]
|
||||||
}, [
|
}, [
|
||||||
|
hasSession,
|
||||||
onToggleSaved,
|
onToggleSaved,
|
||||||
onPressReport,
|
onPressReport,
|
||||||
onPressShare,
|
onPressShare,
|
||||||
|
@ -339,7 +340,7 @@ export function ProfileFeedScreenInner({
|
||||||
: undefined
|
: undefined
|
||||||
}
|
}
|
||||||
avatarType="algo">
|
avatarType="algo">
|
||||||
{feedInfo && (
|
{feedInfo && hasSession && (
|
||||||
<>
|
<>
|
||||||
<Button
|
<Button
|
||||||
disabled={isSavePending || isRemovePending}
|
disabled={isSavePending || isRemovePending}
|
||||||
|
@ -374,6 +375,7 @@ export function ProfileFeedScreenInner({
|
||||||
)
|
)
|
||||||
}, [
|
}, [
|
||||||
_,
|
_,
|
||||||
|
hasSession,
|
||||||
pal,
|
pal,
|
||||||
feedInfo,
|
feedInfo,
|
||||||
isPinned,
|
isPinned,
|
||||||
|
@ -509,6 +511,7 @@ function AboutSection({
|
||||||
const {_} = useLingui()
|
const {_} = useLingui()
|
||||||
const scrollHandler = useAnimatedScrollHandler(onScroll)
|
const scrollHandler = useAnimatedScrollHandler(onScroll)
|
||||||
const [likeUri, setLikeUri] = React.useState(feedInfo.likeUri)
|
const [likeUri, setLikeUri] = React.useState(feedInfo.likeUri)
|
||||||
|
const {hasSession} = useSession()
|
||||||
|
|
||||||
const {mutateAsync: likeFeed, isPending: isLikePending} = useLikeMutation()
|
const {mutateAsync: likeFeed, isPending: isLikePending} = useLikeMutation()
|
||||||
const {mutateAsync: unlikeFeed, isPending: isUnlikePending} =
|
const {mutateAsync: unlikeFeed, isPending: isUnlikePending} =
|
||||||
|
@ -574,7 +577,7 @@ function AboutSection({
|
||||||
testID="toggleLikeBtn"
|
testID="toggleLikeBtn"
|
||||||
accessibilityLabel={_(msg`Like this feed`)}
|
accessibilityLabel={_(msg`Like this feed`)}
|
||||||
accessibilityHint=""
|
accessibilityHint=""
|
||||||
disabled={isLikePending || isUnlikePending}
|
disabled={!hasSession || isLikePending || isUnlikePending}
|
||||||
onPress={onToggleLiked}
|
onPress={onToggleLiked}
|
||||||
style={{paddingHorizontal: 10}}>
|
style={{paddingHorizontal: 10}}>
|
||||||
{isLiked ? (
|
{isLiked ? (
|
||||||
|
|
Loading…
Reference in New Issue