Fix localization for Following and Discover feed names (#11572)

This commit is contained in:
DS Boyce
2026-09-02 07:24:34 -07:00
committed by GitHub
parent f288e18baa
commit 701d7c4659
5 changed files with 56 additions and 25 deletions
+9 -5
View File
@@ -1,7 +1,10 @@
import {useCallback, useMemo} from 'react'
import {useLingui} from '@lingui/react/macro'
import {useNavigation} from '@react-navigation/native'
import {TIMELINE_SAVED_FEED} from '#/lib/constants'
import {type NavigationProp} from '#/lib/routes/types'
import {getLocalizedFeedName} from '#/lib/strings/feed-names'
import {type FeedSourceInfo} from '#/state/queries/feed'
import {useSession} from '#/state/session'
import {type RenderTabBarFnProps} from '#/view/com/pager/Pager'
@@ -12,28 +15,29 @@ export function HomeHeader(
props: RenderTabBarFnProps & {
testID?: string
onPressSelected: () => void
feeds: FeedSourceInfo[]
feeds: Pick<FeedSourceInfo, 'displayName' | 'uri'>[]
},
) {
const {feeds, onSelect: onSelectProp} = props
const {hasSession} = useSession()
const {t: l, i18n} = useLingui()
const navigation = useNavigation<NavigationProp>()
const hasPinnedCustom = useMemo<boolean>(() => {
if (!hasSession) return false
return feeds.some(tab => {
const isFollowing = tab.uri === 'following'
const isFollowing = tab.uri === TIMELINE_SAVED_FEED.value
return !isFollowing
})
}, [feeds, hasSession])
const items = useMemo(() => {
const pinnedNames = feeds.map(f => f.displayName)
const pinnedNames = feeds.map(f => getLocalizedFeedName(f, i18n))
if (!hasPinnedCustom) {
return pinnedNames.concat('Feeds ✨')
return pinnedNames.concat(l`Feeds ✨`)
}
return pinnedNames
}, [hasPinnedCustom, feeds])
}, [i18n, l, hasPinnedCustom, feeds])
const onPressFeedsLink = useCallback(() => {
navigation.navigate('Feeds')