[PWI] Feeds (#1970)

* Feeds page

* Hide save buttons on Feeds page

* ProfileFeed
zio/stable
Eric Bailey 2023-11-21 17:36:29 -06:00 committed by GitHub
parent 8da10a5edc
commit 3de1d556a9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 49 additions and 39 deletions

View File

@ -34,6 +34,7 @@ import {
} from '#/state/queries/feed'
import {cleanError} from 'lib/strings/errors'
import {useComposerControls} from '#/state/shell/composer'
import {useSession} from '#/state/session'
type Props = NativeStackScreenProps<FeedsTabNavigatorParams, 'Feeds'>
@ -117,6 +118,7 @@ export const FeedsScreen = withAuthRequired(
isPending: isSearchPending,
error: searchError,
} = useSearchPopularFeedsMutation()
const {hasSession} = useSession()
/**
* A search query is present. We may not have search results yet.
@ -180,6 +182,7 @@ export const FeedsScreen = withAuthRequired(
const items = React.useMemo(() => {
let slices: FlatlistSlice[] = []
if (hasSession) {
slices.push({
key: 'savedFeedsHeader',
type: 'savedFeedsHeader',
@ -227,6 +230,7 @@ export const FeedsScreen = withAuthRequired(
}
}
}
}
slices.push({
key: 'popularFeedsHeader',
@ -307,6 +311,7 @@ export const FeedsScreen = withAuthRequired(
return slices
}, [
hasSession,
preferences,
isPreferencesLoading,
preferencesError,
@ -393,7 +398,8 @@ export const FeedsScreen = withAuthRequired(
pal.view,
styles.header,
{
marginTop: 16,
// This is first in the flatlist without a session -esb
marginTop: hasSession ? 16 : 0,
paddingLeft: isMobile ? 12 : undefined,
paddingRight: 10,
paddingBottom: isMobile ? 6 : undefined,
@ -432,7 +438,7 @@ export const FeedsScreen = withAuthRequired(
return (
<FeedSourceCard
feedUri={item.feedUri}
showSaveBtn
showSaveBtn={hasSession}
showDescription
showLikes
/>
@ -455,6 +461,7 @@ export const FeedsScreen = withAuthRequired(
},
[
_,
hasSession,
isMobile,
pal,
query,

View File

@ -165,7 +165,7 @@ export function ProfileFeedScreenInner({
}) {
const {_} = useLingui()
const pal = usePalette('default')
const {currentAccount} = useSession()
const {hasSession, currentAccount} = useSession()
const {openModal} = useModalControls()
const {openComposer} = useComposerControls()
const {track} = useAnalytics()
@ -270,7 +270,7 @@ export function ProfileFeedScreenInner({
const dropdownItems: DropdownItem[] = React.useMemo(() => {
return [
{
hasSession && {
testID: 'feedHeaderDropdownToggleSavedBtn',
label: isSaved ? _(msg`Remove from my feeds`) : _(msg`Add to my feeds`),
onPress: isSavePending || isRemovePending ? undefined : onToggleSaved,
@ -290,7 +290,7 @@ export function ProfileFeedScreenInner({
web: 'plus',
},
},
{
hasSession && {
testID: 'feedHeaderDropdownReportBtn',
label: _(msg`Report feed`),
onPress: onPressReport,
@ -314,8 +314,9 @@ export function ProfileFeedScreenInner({
web: 'share',
},
},
] as DropdownItem[]
].filter(Boolean) as DropdownItem[]
}, [
hasSession,
onToggleSaved,
onPressReport,
onPressShare,
@ -339,7 +340,7 @@ export function ProfileFeedScreenInner({
: undefined
}
avatarType="algo">
{feedInfo && (
{feedInfo && hasSession && (
<>
<Button
disabled={isSavePending || isRemovePending}
@ -374,6 +375,7 @@ export function ProfileFeedScreenInner({
)
}, [
_,
hasSession,
pal,
feedInfo,
isPinned,
@ -509,6 +511,7 @@ function AboutSection({
const {_} = useLingui()
const scrollHandler = useAnimatedScrollHandler(onScroll)
const [likeUri, setLikeUri] = React.useState(feedInfo.likeUri)
const {hasSession} = useSession()
const {mutateAsync: likeFeed, isPending: isLikePending} = useLikeMutation()
const {mutateAsync: unlikeFeed, isPending: isUnlikePending} =
@ -574,7 +577,7 @@ function AboutSection({
testID="toggleLikeBtn"
accessibilityLabel={_(msg`Like this feed`)}
accessibilityHint=""
disabled={isLikePending || isUnlikePending}
disabled={!hasSession || isLikePending || isUnlikePending}
onPress={onToggleLiked}
style={{paddingHorizontal: 10}}>
{isLiked ? (