Handle saved feed screen edge case

This commit is contained in:
Eric Bailey
2024-04-18 10:34:51 -05:00
parent 6a8b670ae3
commit aa1d1c23a5
3 changed files with 86 additions and 65 deletions
+11 -8
View File
@@ -193,11 +193,9 @@ export function FeedSourceCardLoaded({
</View> </View>
) )
const showFeedSaveButton = showSaveBtn && feed.type === 'feed' const primaryAlgo = preferences?.primaryAlgorithm
const isPrimaryAlgo = const isPrimaryAlgo =
preferences.primaryAlgorithm?.enabled && primaryAlgo?.enabled && primaryAlgo?.uri && primaryAlgo.uri === feed.uri
preferences.primaryAlgorithm?.uri &&
preferences.primaryAlgorithm.uri === feed.uri
return ( return (
<> <>
@@ -236,8 +234,9 @@ export function FeedSourceCardLoaded({
</Text> </Text>
</View> </View>
{showFeedSaveButton && {showSaveBtn && feed.type === 'feed' && (
(gate('reduced_onboarding_and_home_algo') && isPrimaryAlgo ? ( <>
{gate('reduced_onboarding_and_home_algo') && isPrimaryAlgo ? (
<Button <Button
variant="solid" variant="solid"
color="secondary" color="secondary"
@@ -249,7 +248,9 @@ export function FeedSourceCardLoaded({
primaryAlgoDialogControl.open() primaryAlgoDialogControl.open()
}}> }}>
<ButtonIcon icon={Check} position="left" /> <ButtonIcon icon={Check} position="left" />
<ButtonText>Primary Algorithm</ButtonText> <ButtonText>
<Trans>Primary Algorithm</Trans>
</ButtonText>
</Button> </Button>
) : ( ) : (
<View style={[s.justifyCenter]}> <View style={[s.justifyCenter]}>
@@ -281,7 +282,9 @@ export function FeedSourceCardLoaded({
)} )}
</Pressable> </Pressable>
</View> </View>
))} )}
</>
)}
</View> </View>
{showDescription && feed.description ? ( {showDescription && feed.description ? (
+3 -1
View File
@@ -341,7 +341,9 @@ export function ProfileFeedScreenInner({
primaryAlgoDialogControl.open() primaryAlgoDialogControl.open()
}}> }}>
<ButtonIcon icon={Check} position="left" /> <ButtonIcon icon={Check} position="left" />
<ButtonText>Primary Algorithm</ButtonText> <ButtonText>
<Trans>Primary Algorithm</Trans>
</ButtonText>
</NewButton> </NewButton>
) : ( ) : (
<NewButton <NewButton
+17 -1
View File
@@ -7,6 +7,7 @@ import {useFocusEffect} from '@react-navigation/native'
import {NativeStackScreenProps} from '@react-navigation/native-stack' import {NativeStackScreenProps} from '@react-navigation/native-stack'
import {track} from '#/lib/analytics/analytics' import {track} from '#/lib/analytics/analytics'
import {useGate} from '#/lib/statsig/statsig'
import {logger} from '#/logger' import {logger} from '#/logger'
import { import {
usePinFeedMutation, usePinFeedMutation,
@@ -14,6 +15,7 @@ import {
useSetSaveFeedsMutation, useSetSaveFeedsMutation,
useUnpinFeedMutation, useUnpinFeedMutation,
} from '#/state/queries/preferences' } from '#/state/queries/preferences'
import {UsePreferencesQueryResponse} from '#/state/queries/preferences/types'
import {useSetMinimalShellMode} from '#/state/shell' import {useSetMinimalShellMode} from '#/state/shell'
import {useAnalytics} from 'lib/analytics/analytics' import {useAnalytics} from 'lib/analytics/analytics'
import {useHaptics} from 'lib/haptics' import {useHaptics} from 'lib/haptics'
@@ -112,6 +114,7 @@ export function SavedFeeds({}: Props) {
setSavedFeeds={setSavedFeeds} setSavedFeeds={setSavedFeeds}
resetSaveFeedsMutationState={resetSaveFeedsMutationState} resetSaveFeedsMutationState={resetSaveFeedsMutationState}
currentFeeds={currentFeeds} currentFeeds={currentFeeds}
preferences={preferences}
/> />
)) ))
) )
@@ -145,6 +148,7 @@ export function SavedFeeds({}: Props) {
setSavedFeeds={setSavedFeeds} setSavedFeeds={setSavedFeeds}
resetSaveFeedsMutationState={resetSaveFeedsMutationState} resetSaveFeedsMutationState={resetSaveFeedsMutationState}
currentFeeds={currentFeeds} currentFeeds={currentFeeds}
preferences={preferences}
/> />
)) ))
) )
@@ -179,6 +183,7 @@ function ListItem({
currentFeeds, currentFeeds,
setSavedFeeds, setSavedFeeds,
resetSaveFeedsMutationState, resetSaveFeedsMutationState,
preferences,
}: { }: {
feedUri: string // uri feedUri: string // uri
isPinned: boolean isPinned: boolean
@@ -187,6 +192,7 @@ function ListItem({
resetSaveFeedsMutationState: ReturnType< resetSaveFeedsMutationState: ReturnType<
typeof useSetSaveFeedsMutation typeof useSetSaveFeedsMutation
>['reset'] >['reset']
preferences: UsePreferencesQueryResponse
}) { }) {
const pal = usePalette('default') const pal = usePalette('default')
const {_} = useLingui() const {_} = useLingui()
@@ -195,6 +201,13 @@ function ListItem({
const {isPending: isUnpinPending, mutateAsync: unpinFeed} = const {isPending: isUnpinPending, mutateAsync: unpinFeed} =
useUnpinFeedMutation() useUnpinFeedMutation()
const isPending = isPinPending || isUnpinPending 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 () => { const onTogglePinned = React.useCallback(async () => {
playHaptic() playHaptic()
@@ -303,6 +316,8 @@ function ListItem({
showSaveBtn showSaveBtn
showMinimalPlaceholder showMinimalPlaceholder
/> />
{showPinButton && (
<View style={{paddingRight: 16}}>
<Pressable <Pressable
disabled={isPending} disabled={isPending}
accessibilityRole="button" accessibilityRole="button"
@@ -317,6 +332,8 @@ function ListItem({
color={isPinned ? colors.blue3 : pal.colors.icon} color={isPinned ? colors.blue3 : pal.colors.icon}
/> />
</Pressable> </Pressable>
</View>
)}
</Pressable> </Pressable>
) )
} }
@@ -345,7 +362,6 @@ const styles = StyleSheet.create({
flexDirection: 'row', flexDirection: 'row',
alignItems: 'center', alignItems: 'center',
borderBottomWidth: 1, borderBottomWidth: 1,
paddingRight: 16,
}, },
webArrowButtonsContainer: { webArrowButtonsContainer: {
paddingLeft: 16, paddingLeft: 16,