From aa1d1c23a58592b3fa12aba5fdb41627d3548622 Mon Sep 17 00:00:00 2001 From: Eric Bailey Date: Thu, 18 Apr 2024 10:34:51 -0500 Subject: [PATCH] Handle saved feed screen edge case --- src/view/com/feeds/FeedSourceCard.tsx | 101 +++++++++++++------------- src/view/screens/ProfileFeed.tsx | 4 +- src/view/screens/SavedFeeds.tsx | 46 ++++++++---- 3 files changed, 86 insertions(+), 65 deletions(-) diff --git a/src/view/com/feeds/FeedSourceCard.tsx b/src/view/com/feeds/FeedSourceCard.tsx index c1caeb7149..c5cd9ff4c8 100644 --- a/src/view/com/feeds/FeedSourceCard.tsx +++ b/src/view/com/feeds/FeedSourceCard.tsx @@ -193,11 +193,9 @@ export function FeedSourceCardLoaded({ ) - const showFeedSaveButton = showSaveBtn && feed.type === 'feed' + const primaryAlgo = preferences?.primaryAlgorithm const isPrimaryAlgo = - preferences.primaryAlgorithm?.enabled && - preferences.primaryAlgorithm?.uri && - preferences.primaryAlgorithm.uri === feed.uri + primaryAlgo?.enabled && primaryAlgo?.uri && primaryAlgo.uri === feed.uri return ( <> @@ -236,52 +234,57 @@ export function FeedSourceCardLoaded({ - {showFeedSaveButton && - (gate('reduced_onboarding_and_home_algo') && isPrimaryAlgo ? ( - - ) : ( - - - {isSaved ? ( - - ) : ( - + {showSaveBtn && feed.type === 'feed' && ( + <> + {gate('reduced_onboarding_and_home_algo') && isPrimaryAlgo ? ( + + ) : ( + + + {isSaved ? ( + + ) : ( + + )} + + + )} + + )} {showDescription && feed.description ? ( diff --git a/src/view/screens/ProfileFeed.tsx b/src/view/screens/ProfileFeed.tsx index 16d88fed70..270e59eea7 100644 --- a/src/view/screens/ProfileFeed.tsx +++ b/src/view/screens/ProfileFeed.tsx @@ -341,7 +341,9 @@ export function ProfileFeedScreenInner({ primaryAlgoDialogControl.open() }}> - Primary Algorithm + + Primary Algorithm + ) : ( )) ) @@ -145,6 +148,7 @@ export function SavedFeeds({}: Props) { setSavedFeeds={setSavedFeeds} resetSaveFeedsMutationState={resetSaveFeedsMutationState} currentFeeds={currentFeeds} + preferences={preferences} /> )) ) @@ -179,6 +183,7 @@ function ListItem({ currentFeeds, setSavedFeeds, resetSaveFeedsMutationState, + preferences, }: { feedUri: string // uri isPinned: boolean @@ -187,6 +192,7 @@ function ListItem({ resetSaveFeedsMutationState: ReturnType< typeof useSetSaveFeedsMutation >['reset'] + preferences: UsePreferencesQueryResponse }) { const pal = usePalette('default') const {_} = useLingui() @@ -195,6 +201,13 @@ function ListItem({ const {isPending: isUnpinPending, mutateAsync: unpinFeed} = useUnpinFeedMutation() const isPending = isPinPending || isUnpinPending + const gate = useGate() + const primaryAlgo = preferences.primaryAlgorithm + const isPrimaryAlgoExperimentEnabled = gate( + 'reduced_onboarding_and_home_algo', + ) + const isPrimaryAlgo = primaryAlgo?.enabled && primaryAlgo?.uri === feedUri + const showPinButton = !(isPrimaryAlgoExperimentEnabled && isPrimaryAlgo) const onTogglePinned = React.useCallback(async () => { playHaptic() @@ -303,20 +316,24 @@ function ListItem({ showSaveBtn showMinimalPlaceholder /> - ({ - opacity: state.hovered || state.focused || isPending ? 0.5 : 1, - })}> - - + {showPinButton && ( + + ({ + opacity: state.hovered || state.focused || isPending ? 0.5 : 1, + })}> + + + + )} ) } @@ -345,7 +362,6 @@ const styles = StyleSheet.create({ flexDirection: 'row', alignItems: 'center', borderBottomWidth: 1, - paddingRight: 16, }, webArrowButtonsContainer: { paddingLeft: 16,