diff --git a/src/lib/hooks/useOnMainScroll.ts b/src/lib/hooks/useOnMainScroll.ts index 491a9a71ba..d65c307fa2 100644 --- a/src/lib/hooks/useOnMainScroll.ts +++ b/src/lib/hooks/useOnMainScroll.ts @@ -1,5 +1,5 @@ import {useCallback, useMemo} from 'react' -import {NativeSyntheticEvent, NativeScrollEvent} from 'react-native' +import {NativeScrollEvent} from 'react-native' import {useSetMinimalShellMode, useMinimalShellMode} from '#/state/shell' import {useShellLayout} from '#/state/shell/shell-layout' import {isWeb} from 'platform/detection' @@ -14,13 +14,9 @@ function clamp(num: number, min: number, max: number) { return Math.min(Math.max(num, min), max) } -export type OnScrollCb = ( - event: NativeSyntheticEvent, -) => void -export type OnScrollHandler = ScrollHandlers export type ResetCb = () => void -export function useOnMainScroll(): [OnScrollHandler, ResetCb] { +export function useOnMainScroll(): [ScrollHandlers, ResetCb] { const {headerHeight} = useShellLayout() const mode = useMinimalShellMode() const setMode = useSetMinimalShellMode() diff --git a/src/view/com/feeds/FeedPage.tsx b/src/view/com/feeds/FeedPage.tsx index 458c0c72de..606ffa4ab4 100644 --- a/src/view/com/feeds/FeedPage.tsx +++ b/src/view/com/feeds/FeedPage.tsx @@ -173,10 +173,8 @@ export function FeedPage({ feedParams={feedParams} pollInterval={POLL_FREQ} scrollElRef={scrollElRef} - onScroll={onMainScroll} onScrolledDownChange={setIsScrolledDown} onHasNew={setHasNew} - scrollEventThrottle={1} renderEmptyState={renderEmptyState} renderEndOfFeed={renderEndOfFeed} ListHeaderComponent={ListHeaderComponent} diff --git a/src/view/com/feeds/ProfileFeedgens.tsx b/src/view/com/feeds/ProfileFeedgens.tsx index 73e8ee3f85..ff65055011 100644 --- a/src/view/com/feeds/ProfileFeedgens.tsx +++ b/src/view/com/feeds/ProfileFeedgens.tsx @@ -15,11 +15,9 @@ import {LoadMoreRetryBtn} from '../util/LoadMoreRetryBtn' import {Text} from '../util/text/Text' import {usePalette} from 'lib/hooks/usePalette' import {useProfileFeedgensQuery, RQKEY} from '#/state/queries/profile-feedgens' -import {OnScrollHandler} from '#/lib/hooks/useOnMainScroll' import {logger} from '#/logger' import {Trans} from '@lingui/macro' import {cleanError} from '#/lib/strings/errors' -import {useAnimatedScrollHandler} from '#/lib/hooks/useAnimatedScrollHandler_FIXED' import {useTheme} from '#/lib/ThemeContext' import {usePreferencesQuery} from '#/state/queries/preferences' import {hydrateFeedGenerator} from '#/state/queries/feed' @@ -38,8 +36,6 @@ interface SectionRef { interface ProfileFeedgensProps { did: string scrollElRef: ListRef - onScroll?: OnScrollHandler - scrollEventThrottle?: number headerOffset: number enabled?: boolean style?: StyleProp @@ -50,16 +46,7 @@ export const ProfileFeedgens = React.forwardRef< SectionRef, ProfileFeedgensProps >(function ProfileFeedgensImpl( - { - did, - scrollElRef, - onScroll, - scrollEventThrottle, - headerOffset, - enabled, - style, - testID, - }, + {did, scrollElRef, headerOffset, enabled, style, testID}, ref, ) { const pal = usePalette('default') @@ -185,7 +172,6 @@ export const ProfileFeedgens = React.forwardRef< [error, refetch, onPressRetryLoadMore, pal, preferences], ) - const scrollHandler = useAnimatedScrollHandler(onScroll || {}) return ( scrollElRef?: ListRef - onScroll: OnScrollHandler onScrolledDownChange: (isScrolledDown: boolean) => void onPressTryAgain?: () => void renderHeader: () => JSX.Element renderEmptyState: () => JSX.Element testID?: string - scrollEventThrottle?: number headerOffset?: number desktopFixedHeightOffset?: number }) { @@ -211,7 +205,6 @@ export function ListMembers({ [isFetching], ) - const scrollHandler = useAnimatedScrollHandler(onScroll) return ( @@ -47,16 +43,7 @@ interface ProfileListsProps { export const ProfileLists = React.forwardRef( function ProfileListsImpl( - { - did, - scrollElRef, - onScroll, - scrollEventThrottle, - headerOffset, - enabled, - style, - testID, - }, + {did, scrollElRef, headerOffset, enabled, style, testID}, ref, ) { const pal = usePalette('default') @@ -187,7 +174,6 @@ export const ProfileLists = React.forwardRef( [error, refetch, onPressRetryLoadMore, pal], ) - const scrollHandler = useAnimatedScrollHandler(onScroll || {}) return ( ( minHeight: Dimensions.get('window').height * 1.5, }} style={{paddingTop: headerOffset}} - onScroll={onScroll != null ? scrollHandler : undefined} - scrollEventThrottle={scrollEventThrottle} indicatorStyle={theme.colorScheme === 'dark' ? 'white' : 'black'} removeClippedSubviews={true} contentOffset={{x: 0, y: headerOffset * -1}} diff --git a/src/view/com/notifications/Feed.tsx b/src/view/com/notifications/Feed.tsx index 8dec5d5d12..52d534c4fd 100644 --- a/src/view/com/notifications/Feed.tsx +++ b/src/view/com/notifications/Feed.tsx @@ -6,8 +6,6 @@ import {NotificationFeedLoadingPlaceholder} from '../util/LoadingPlaceholder' import {ErrorMessage} from '../util/error/ErrorMessage' import {LoadMoreRetryBtn} from '../util/LoadMoreRetryBtn' import {EmptyState} from '../util/EmptyState' -import {OnScrollHandler} from 'lib/hooks/useOnMainScroll' -import {useAnimatedScrollHandler} from '#/lib/hooks/useAnimatedScrollHandler_FIXED' import {s} from 'lib/styles' import {usePalette} from 'lib/hooks/usePalette' import {useNotificationFeedQuery} from '#/state/queries/notifications/feed' @@ -24,13 +22,11 @@ const LOADING_ITEM = {_reactKey: '__loading__'} export function Feed({ scrollElRef, onPressTryAgain, - onScroll, onScrolledDownChange, ListHeaderComponent, }: { scrollElRef?: ListRef onPressTryAgain?: () => void - onScroll?: OnScrollHandler onScrolledDownChange: (isScrolledDown: boolean) => void ListHeaderComponent?: () => JSX.Element }) { @@ -138,7 +134,6 @@ export function Feed({ [isFetchingNextPage], ) - const scrollHandler = useAnimatedScrollHandler(onScroll || {}) return ( {error && ( @@ -167,9 +162,7 @@ export function Feed({ } onEndReached={onEndReached} onEndReachedThreshold={0.6} - onScroll={scrollHandler} onScrolledDownChange={onScrolledDownChange} - scrollEventThrottle={1} contentContainerStyle={s.contentContainer} // @ts-ignore our .web version only -prf desktopFixedHeight diff --git a/src/view/com/pager/PagerWithHeader.tsx b/src/view/com/pager/PagerWithHeader.tsx index 570163b3d3..6feb80dbae 100644 --- a/src/view/com/pager/PagerWithHeader.tsx +++ b/src/view/com/pager/PagerWithHeader.tsx @@ -19,14 +19,12 @@ import Animated, { import {Pager, PagerRef, RenderTabBarFnProps} from 'view/com/pager/Pager' import {TabBar} from './TabBar' import {useWebMediaQueries} from 'lib/hooks/useWebMediaQueries' -import {OnScrollHandler} from 'lib/hooks/useOnMainScroll' import {useNonReactiveCallback} from '#/lib/hooks/useNonReactiveCallback' import {ListMethods} from '../util/List' export interface PagerWithHeaderChildParams { headerHeight: number isFocused: boolean - onScroll: OnScrollHandler scrollElRef: React.MutableRefObject } diff --git a/src/view/com/posts/Feed.tsx b/src/view/com/posts/Feed.tsx index 081ff10f78..9194bb163d 100644 --- a/src/view/com/posts/Feed.tsx +++ b/src/view/com/posts/Feed.tsx @@ -15,10 +15,8 @@ import {PostFeedLoadingPlaceholder} from '../util/LoadingPlaceholder' import {FeedErrorMessage} from './FeedErrorMessage' import {FeedSlice} from './FeedSlice' import {LoadMoreRetryBtn} from '../util/LoadMoreRetryBtn' -import {OnScrollHandler} from 'lib/hooks/useOnMainScroll' import {useAnalytics} from 'lib/analytics/analytics' import {usePalette} from 'lib/hooks/usePalette' -import {useAnimatedScrollHandler} from '#/lib/hooks/useAnimatedScrollHandler_FIXED' import {useTheme} from 'lib/ThemeContext' import {logger} from '#/logger' import { @@ -45,10 +43,8 @@ let Feed = ({ enabled, pollInterval, scrollElRef, - onScroll, onScrolledDownChange, onHasNew, - scrollEventThrottle, renderEmptyState, renderEndOfFeed, testID, @@ -65,9 +61,7 @@ let Feed = ({ pollInterval?: number scrollElRef?: ListRef onHasNew?: (v: boolean) => void - onScroll?: OnScrollHandler onScrolledDownChange?: (isScrolledDown: boolean) => void - scrollEventThrottle?: number renderEmptyState: () => JSX.Element renderEndOfFeed?: () => JSX.Element testID?: string @@ -272,7 +266,6 @@ let Feed = ({ ) }, [isFetchingNextPage, shouldRenderEndOfFeed, renderEndOfFeed, headerOffset]) - const scrollHandler = useAnimatedScrollHandler(onScroll || {}) return ( ( }, }) - return + return ( + + ) } export const List = React.forwardRef(ListImpl) as ( diff --git a/src/view/com/util/ViewSelector.tsx b/src/view/com/util/ViewSelector.tsx index 978099c48f..ee993c564d 100644 --- a/src/view/com/util/ViewSelector.tsx +++ b/src/view/com/util/ViewSelector.tsx @@ -1,5 +1,7 @@ import React, {useEffect, useState} from 'react' import { + NativeSyntheticEvent, + NativeScrollEvent, Pressable, RefreshControl, StyleSheet, @@ -7,7 +9,6 @@ import { ScrollView, } from 'react-native' import {FlatList_INTERNAL} from './Views' -import {OnScrollCb} from 'lib/hooks/useOnMainScroll' import {useColorSchemeStyle} from 'lib/hooks/useColorSchemeStyle' import {Text} from './text/Text' import {usePalette} from 'lib/hooks/usePalette' @@ -38,7 +39,7 @@ export const ViewSelector = React.forwardRef< | null | undefined onSelectView?: (viewIndex: number) => void - onScroll?: OnScrollCb + onScroll?: (event: NativeSyntheticEvent) => void onRefresh?: () => void onEndReached?: (info: {distanceFromEnd: number}) => void } diff --git a/src/view/screens/Notifications.tsx b/src/view/screens/Notifications.tsx index d707ae01dd..d13e6aa65a 100644 --- a/src/view/screens/Notifications.tsx +++ b/src/view/screens/Notifications.tsx @@ -133,7 +133,6 @@ export function NotificationsScreen({}: Props) { - {({onScroll, headerHeight, isFocused, scrollElRef}) => ( + {({headerHeight, isFocused, scrollElRef}) => ( )} {showRepliesTab - ? ({onScroll, headerHeight, isFocused, scrollElRef}) => ( + ? ({headerHeight, isFocused, scrollElRef}) => ( ) : null} - {({onScroll, headerHeight, isFocused, scrollElRef}) => ( + {({headerHeight, isFocused, scrollElRef}) => ( )} {showLikesTab - ? ({onScroll, headerHeight, isFocused, scrollElRef}) => ( + ? ({headerHeight, isFocused, scrollElRef}) => ( ( + ? ({headerHeight, isFocused, scrollElRef}) => ( ) : null} {showListsTab - ? ({onScroll, headerHeight, isFocused, scrollElRef}) => ( + ? ({headerHeight, isFocused, scrollElRef}) => ( @@ -369,7 +360,6 @@ function ProfileScreenLoaded({ interface FeedSectionProps { feed: FeedDescriptor - onScroll: OnScrollHandler headerHeight: number isFocused: boolean scrollElRef: ListRef @@ -377,7 +367,7 @@ interface FeedSectionProps { } const FeedSection = React.forwardRef( function FeedSectionImpl( - {feed, onScroll, headerHeight, isFocused, scrollElRef, ignoreFilterFor}, + {feed, headerHeight, isFocused, scrollElRef, ignoreFilterFor}, ref, ) { const queryClient = useQueryClient() @@ -408,9 +398,7 @@ const FeedSection = React.forwardRef( feed={feed} scrollElRef={scrollElRef} onHasNew={setHasNew} - onScroll={onScroll} onScrolledDownChange={setIsScrolledDown} - scrollEventThrottle={1} renderEmptyState={renderPostsEmpty} headerOffset={headerHeight} renderEndOfFeed={ProfileEndOfFeed} diff --git a/src/view/screens/ProfileFeed.tsx b/src/view/screens/ProfileFeed.tsx index cfd6f564aa..2886e23bb7 100644 --- a/src/view/screens/ProfileFeed.tsx +++ b/src/view/screens/ProfileFeed.tsx @@ -24,7 +24,6 @@ import {EmptyState} from 'view/com/util/EmptyState' import * as Toast from 'view/com/util/Toast' import {useSetTitle} from 'lib/hooks/useSetTitle' import {RQKEY as FEED_RQKEY} from '#/state/queries/post-feed' -import {OnScrollHandler} from 'lib/hooks/useOnMainScroll' import {shareUrl} from 'lib/sharing' import {toShareUrl} from 'lib/strings/url-helpers' import {Haptics} from 'lib/haptics' @@ -41,7 +40,6 @@ import {logger} from '#/logger' import {Trans, msg} from '@lingui/macro' import {useLingui} from '@lingui/react' import {useModalControls} from '#/state/modals' -import {useAnimatedScrollHandler} from '#/lib/hooks/useAnimatedScrollHandler_FIXED' import { useFeedSourceInfoQuery, FeedSourceFeedInfo, @@ -398,12 +396,11 @@ export function ProfileFeedScreenInner({ isHeaderReady={true} renderHeader={renderHeader} onCurrentPageSelected={onCurrentPageSelected}> - {({onScroll, headerHeight, scrollElRef, isFocused}) => + {({headerHeight, scrollElRef, isFocused}) => isPublicResponse?.isPublic ? ( ) } - {({onScroll, headerHeight, scrollElRef}) => ( + {({headerHeight, scrollElRef}) => ( } @@ -489,16 +485,12 @@ function NonPublicFeedMessage({rawError}: {rawError?: Error}) { interface FeedSectionProps { feed: FeedDescriptor - onScroll: OnScrollHandler headerHeight: number scrollElRef: ListRef isFocused: boolean } const FeedSection = React.forwardRef( - function FeedSectionImpl( - {feed, onScroll, headerHeight, scrollElRef, isFocused}, - ref, - ) { + function FeedSectionImpl({feed, headerHeight, scrollElRef, isFocused}, ref) { const [hasNew, setHasNew] = React.useState(false) const [isScrolledDown, setIsScrolledDown] = React.useState(false) const queryClient = useQueryClient() @@ -528,9 +520,7 @@ const FeedSection = React.forwardRef( pollInterval={30e3} scrollElRef={scrollElRef} onHasNew={setHasNew} - onScroll={onScroll} onScrolledDownChange={setIsScrolledDown} - scrollEventThrottle={5} renderEmptyState={renderPostsEmpty} headerOffset={headerHeight} /> @@ -551,7 +541,6 @@ function AboutSection({ feedRkey, feedInfo, headerHeight, - onScroll, scrollElRef, isOwner, }: { @@ -559,13 +548,13 @@ function AboutSection({ feedRkey: string feedInfo: FeedSourceFeedInfo headerHeight: number - onScroll: OnScrollHandler scrollElRef: React.MutableRefObject isOwner: boolean }) { const pal = usePalette('default') const {_} = useLingui() - const scrollHandler = useAnimatedScrollHandler(onScroll) + // TODO! + const scrollHandler = useAnimatedScrollHandler(() => {}) const [likeUri, setLikeUri] = React.useState(feedInfo.likeUri) const {hasSession} = useSession() const {track} = useAnalytics() @@ -605,8 +594,7 @@ function AboutSection({ contentContainerStyle={{ paddingTop: headerHeight, minHeight: Dimensions.get('window').height * 1.5, - }} - onScroll={scrollHandler}> + }}> - {({onScroll, headerHeight, scrollElRef, isFocused}) => ( + {({headerHeight, scrollElRef, isFocused}) => ( )} - {({onScroll, headerHeight, scrollElRef}) => ( + {({headerHeight, scrollElRef}) => ( )} @@ -204,12 +201,11 @@ function ProfileListScreenLoaded({ items={SECTION_TITLES_MOD} isHeaderReady={true} renderHeader={renderHeader}> - {({onScroll, headerHeight, scrollElRef}) => ( + {({headerHeight, scrollElRef}) => ( )} @@ -595,16 +591,12 @@ function Header({rkey, list}: {rkey: string; list: AppBskyGraphDefs.ListView}) { interface FeedSectionProps { feed: FeedDescriptor - onScroll: OnScrollHandler headerHeight: number scrollElRef: ListRef isFocused: boolean } const FeedSection = React.forwardRef( - function FeedSectionImpl( - {feed, scrollElRef, onScroll, headerHeight, isFocused}, - ref, - ) { + function FeedSectionImpl({feed, scrollElRef, headerHeight, isFocused}, ref) { const queryClient = useQueryClient() const [hasNew, setHasNew] = React.useState(false) const [isScrolledDown, setIsScrolledDown] = React.useState(false) @@ -634,9 +626,7 @@ const FeedSection = React.forwardRef( pollInterval={30e3} scrollElRef={scrollElRef} onHasNew={setHasNew} - onScroll={onScroll} onScrolledDownChange={setIsScrolledDown} - scrollEventThrottle={1} renderEmptyState={renderPostsEmpty} headerOffset={headerHeight} /> @@ -655,13 +645,12 @@ const FeedSection = React.forwardRef( interface AboutSectionProps { list: AppBskyGraphDefs.ListView onPressAddUser: () => void - onScroll: OnScrollHandler headerHeight: number scrollElRef: ListRef } const AboutSection = React.forwardRef( function AboutSectionImpl( - {list, onPressAddUser, onScroll, headerHeight, scrollElRef}, + {list, onPressAddUser, headerHeight, scrollElRef}, ref, ) { const pal = usePalette('default') @@ -798,9 +787,7 @@ const AboutSection = React.forwardRef( renderHeader={renderHeader} renderEmptyState={renderEmptyState} headerOffset={headerHeight} - onScroll={onScroll} onScrolledDownChange={setIsScrolledDown} - scrollEventThrottle={1} /> {isScrolledDown && (