Skip to content

Commit

Permalink
Add back PTR
Browse files Browse the repository at this point in the history
  • Loading branch information
estrattonbailey committed Nov 13, 2023
1 parent 00e397a commit c232682
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/view/screens/Feeds.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from 'react'
import {ActivityIndicator, StyleSheet, View} from 'react-native'
import {ActivityIndicator, StyleSheet, View, RefreshControl} from 'react-native'
import {FontAwesomeIcon} from '@fortawesome/react-native-fontawesome'
import {FontAwesomeIconStyle} from '@fortawesome/react-native-fontawesome'
import {withAuthRequired} from 'view/com/auth/withAuthRequired'
Expand Down Expand Up @@ -94,6 +94,7 @@ export const FeedsScreen = withAuthRequired(function FeedsScreenImpl(
const pal = usePalette('default')
const {isMobile, isTabletOrDesktop} = useWebMediaQueries()
const [query, setQuery] = React.useState('')
const [isPTR, setIsPTR] = React.useState(false)
const {
data: preferences,
isLoading: isPreferencesLoading,
Expand Down Expand Up @@ -148,6 +149,11 @@ export const FeedsScreen = withAuthRequired(function FeedsScreenImpl(
const onSubmitQuery = React.useCallback(() => {
debouncedSearch(query)
}, [query, debouncedSearch])
const onPullToRefresh = React.useCallback(async () => {
setIsPTR(true)
await refetchPopularFeeds()
setIsPTR(false)
}, [setIsPTR, refetchPopularFeeds])

useFocusEffect(
React.useCallback(() => {
Expand Down Expand Up @@ -459,6 +465,14 @@ export const FeedsScreen = withAuthRequired(function FeedsScreenImpl(
keyExtractor={item => item.key}
contentContainerStyle={styles.contentContainer}
renderItem={renderItem}
refreshControl={
<RefreshControl
refreshing={isPTR}
onRefresh={isUserSearching ? undefined : onPullToRefresh}
tintColor={pal.colors.text}
titleColor={pal.colors.text}
/>
}
initialNumToRender={10}
onEndReached={() =>
isUserSearching ? undefined : fetchNextPopularFeedsPage()
Expand Down

0 comments on commit c232682

Please sign in to comment.