Refresh on scroll-to-top by active section press (#1807)

zio/stable
Paul Frazee 2023-11-03 14:53:47 -07:00 committed by GitHub
parent 445f976881
commit 4de852ded8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 4 additions and 13 deletions

View File

@ -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,
@ -420,7 +416,7 @@ const FeedSection = React.forwardRef<SectionRef, FeedSectionProps>(
/>
{(isScrolledDown || hasNew) && (
<LoadLatestBtn
onPress={onPressLoadLatest}
onPress={onScrollToTop}
label="Load new posts"
showIndicator={hasNew}
/>

View File

@ -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,
}))
@ -586,7 +581,7 @@ const FeedSection = React.forwardRef<SectionRef, FeedSectionProps>(
/>
{(isScrolledDown || hasNew) && (
<LoadLatestBtn
onPress={onPressLoadLatest}
onPress={onScrollToTop}
label="Load new posts"
showIndicator={hasNew}
/>