Fix crash when clicking "find people to follow"

This commit is contained in:
Alex Benzer
2025-11-30 15:48:35 -08:00
parent de1368559c
commit fcdc1dd486
+8 -10
View File
@@ -3,7 +3,6 @@ import {
TextInput, TextInput,
useWindowDimensions, useWindowDimensions,
View, View,
type ViewabilityConfig,
type ViewToken, type ViewToken,
} from 'react-native' } from 'react-native'
import {type ModerationOpts} from '@atproto/api' import {type ModerationOpts} from '@atproto/api'
@@ -235,14 +234,17 @@ function DialogInner({guide}: {guide: Follow10ProgressGuide}) {
// Track seen profiles // Track seen profiles
const seenProfilesRef = useRef<Set<string>>(new Set()) const seenProfilesRef = useRef<Set<string>>(new Set())
const onViewableItemsChanged = useCallback( const itemsRef = useRef(items)
itemsRef.current = items
const onViewableItemsChanged = useRef(
({viewableItems}: {viewableItems: ViewToken[]}) => { ({viewableItems}: {viewableItems: ViewToken[]}) => {
for (const viewableItem of viewableItems) { for (const viewableItem of viewableItems) {
const item = viewableItem.item as Item const item = viewableItem.item as Item
if (item.type === 'profile') { if (item.type === 'profile') {
if (!seenProfilesRef.current.has(item.profile.did)) { if (!seenProfilesRef.current.has(item.profile.did)) {
seenProfilesRef.current.add(item.profile.did) seenProfilesRef.current.add(item.profile.did)
const position = items.findIndex( const position = itemsRef.current.findIndex(
i => i.type === 'profile' && i.profile.did === item.profile.did, i => i.type === 'profile' && i.profile.did === item.profile.did,
) )
logger.metric( logger.metric(
@@ -258,14 +260,10 @@ function DialogInner({guide}: {guide: Follow10ProgressGuide}) {
} }
} }
}, },
[items], ).current
) const viewabilityConfig = useRef({
const viewabilityConfig: ViewabilityConfig = useMemo(
() => ({
itemVisiblePercentThreshold: 50, itemVisiblePercentThreshold: 50,
}), }).current
[],
)
const onSelectTab = useCallback( const onSelectTab = useCallback(
(interest: string) => { (interest: string) => {