Skip to content

Commit

Permalink
Refresh on scroll-to-top by active section press (#1807)
Browse files Browse the repository at this point in the history
  • Loading branch information
pfrazee authored Nov 3, 2023
1 parent 445f976 commit 4de852d
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
8 changes: 2 additions & 6 deletions src/view/screens/ProfileFeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -393,12 +393,8 @@ const FeedSection = React.forwardRef<SectionRef, FeedSectionProps>(

const onScrollToTop = useCallback(() => {
scrollElRef.current?.scrollToOffset({offset: -headerHeight})
}, [scrollElRef, headerHeight])

const onPressLoadLatest = React.useCallback(() => {
onScrollToTop()
feed.refresh()
}, [feed, onScrollToTop])
}, [feed, scrollElRef, headerHeight])

React.useImperativeHandle(ref, () => ({
scrollToTop: onScrollToTop,
Expand All @@ -420,7 +416,7 @@ const FeedSection = React.forwardRef<SectionRef, FeedSectionProps>(
/>
{(isScrolledDown || hasNew) && (
<LoadLatestBtn
onPress={onPressLoadLatest}
onPress={onScrollToTop}
label="Load new posts"
showIndicator={hasNew}
/>
Expand Down
9 changes: 2 additions & 7 deletions src/view/screens/ProfileList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -558,13 +558,8 @@ const FeedSection = React.forwardRef<SectionRef, FeedSectionProps>(

const onScrollToTop = useCallback(() => {
scrollElRef.current?.scrollToOffset({offset: -headerHeight})
}, [scrollElRef, headerHeight])

const onPressLoadLatest = React.useCallback(() => {
onScrollToTop()
feed.refresh()
}, [feed, onScrollToTop])

}, [feed, scrollElRef, headerHeight])
React.useImperativeHandle(ref, () => ({
scrollToTop: onScrollToTop,
}))
Expand All @@ -586,7 +581,7 @@ const FeedSection = React.forwardRef<SectionRef, FeedSectionProps>(
/>
{(isScrolledDown || hasNew) && (
<LoadLatestBtn
onPress={onPressLoadLatest}
onPress={onScrollToTop}
label="Load new posts"
showIndicator={hasNew}
/>
Expand Down

0 comments on commit 4de852d

Please sign in to comment.