[🐴] Add end of list text, fix threshold (#4138)

* Add end of list text

* onEndReachedThreshold
zio/stable
Eric Bailey 2024-05-20 21:42:49 -05:00 committed by GitHub
parent ad2d84fb05
commit 6cc040a94e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 18 additions and 2 deletions

View File

@ -13,12 +13,14 @@ import {Text} from '#/components/Typography'
export function ListFooter({ export function ListFooter({
isFetchingNextPage, isFetchingNextPage,
hasNextPage,
error, error,
onRetry, onRetry,
height, height,
style, style,
}: { }: {
isFetchingNextPage?: boolean isFetchingNextPage?: boolean
hasNextPage?: boolean
error?: string error?: string
onRetry?: () => Promise<unknown> onRetry?: () => Promise<unknown>
height?: number height?: number
@ -40,7 +42,19 @@ export function ListFooter({
{isFetchingNextPage ? ( {isFetchingNextPage ? (
<Loader size="xl" /> <Loader size="xl" />
) : ( ) : (
<ListFooterMaybeError error={error} onRetry={onRetry} /> <>
{error ? (
<ListFooterMaybeError error={error} onRetry={onRetry} />
) : (
<>
{!hasNextPage && (
<Text style={[a.text_sm, t.atoms.text_contrast_low]}>
<Trans>End of list</Trans>
</Text>
)}
</>
)}
</>
)} )}
</View> </View>
) )

View File

@ -9,6 +9,7 @@ import {useInitialNumToRender} from '#/lib/hooks/useInitialNumToRender'
import {MessagesTabNavigatorParams} from '#/lib/routes/types' import {MessagesTabNavigatorParams} from '#/lib/routes/types'
import {cleanError} from '#/lib/strings/errors' import {cleanError} from '#/lib/strings/errors'
import {logger} from '#/logger' import {logger} from '#/logger'
import {isNative} from '#/platform/detection'
import {useListConvos} from '#/state/queries/messages/list-converations' import {useListConvos} from '#/state/queries/messages/list-converations'
import {List} from '#/view/com/util/List' import {List} from '#/view/com/util/List'
import {ViewHeader} from '#/view/com/util/ViewHeader' import {ViewHeader} from '#/view/com/util/ViewHeader'
@ -248,9 +249,10 @@ export function MessagesScreen({navigation, route}: Props) {
error={cleanError(error)} error={cleanError(error)}
onRetry={fetchNextPage} onRetry={fetchNextPage}
style={{borderColor: 'transparent'}} style={{borderColor: 'transparent'}}
hasNextPage={hasNextPage}
/> />
} }
onEndReachedThreshold={3} onEndReachedThreshold={isNative ? 1.5 : 0}
initialNumToRender={initialNumToRender} initialNumToRender={initialNumToRender}
windowSize={11} windowSize={11}
// @ts-ignore our .web version only -sfn // @ts-ignore our .web version only -sfn