mirror of https://git.lenooby09.tech/LeNooby09/social-app.git
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Adjust FlatList performance in main feeds (#3134)

* adjust flatlist perf settings

* calculate initial num to render based on screen height

* adjust window size

* don't react to screen height changes

authored by hailey.at and committed by

GitHub 8b0e575f 357b61d0

+19
+11
src/lib/hooks/useInitialNumToRender.ts
··· 1 + import React from 'react' 2 + import {Dimensions} from 'react-native' 3 + 4 + const MIN_POST_HEIGHT = 100 5 + 6 + export function useInitialNumToRender(minItemHeight: number = MIN_POST_HEIGHT) { 7 + return React.useMemo(() => { 8 + const screenHeight = Dimensions.get('window').height 9 + return Math.ceil(screenHeight / minItemHeight) + 1 10 + }, [minItemHeight]) 11 + }
+4
src/screens/Hashtag.tsx
··· 22 22 import {shareUrl} from 'lib/sharing' 23 23 import {HITSLOP_10} from 'lib/constants' 24 24 import {isNative} from 'platform/detection' 25 + import {useInitialNumToRender} from 'lib/hooks/useInitialNumToRender' 25 26 26 27 const renderItem = ({item}: ListRenderItemInfo<PostView>) => { 27 28 return <Post post={item} /> ··· 37 38 const {tag, author} = route.params 38 39 const setMinimalShellMode = useSetMinimalShellMode() 39 40 const {_} = useLingui() 41 + const initialNumToRender = useInitialNumToRender() 40 42 const [isPTR, setIsPTR] = React.useState(false) 41 43 42 44 const fullTag = React.useMemo(() => { ··· 154 156 onRetry={fetchNextPage} 155 157 /> 156 158 } 159 + initialNumToRender={initialNumToRender} 160 + windowSize={11} 157 161 /> 158 162 )} 159 163 </>
+4
src/view/com/posts/Feed.tsx
··· 32 32 import {useLingui} from '@lingui/react' 33 33 import {DiscoverFallbackHeader} from './DiscoverFallbackHeader' 34 34 import {FALLBACK_MARKER_POST} from '#/lib/api/feed/home' 35 + import {useInitialNumToRender} from 'lib/hooks/useInitialNumToRender' 35 36 36 37 const LOADING_ITEM = {_reactKey: '__loading__'} 37 38 const EMPTY_FEED_ITEM = {_reactKey: '__empty__'} ··· 84 85 const {_} = useLingui() 85 86 const queryClient = useQueryClient() 86 87 const {currentAccount} = useSession() 88 + const initialNumToRender = useInitialNumToRender() 87 89 const [isPTRing, setIsPTRing] = React.useState(false) 88 90 const checkForNewRef = React.useRef<(() => void) | null>(null) 89 91 const lastFetchRef = React.useRef<number>(Date.now()) ··· 327 329 desktopFixedHeight={ 328 330 desktopFixedHeightOffset ? desktopFixedHeightOffset : true 329 331 } 332 + initialNumToRender={initialNumToRender} 333 + windowSize={11} 330 334 /> 331 335 </View> 332 336 )