Improve refresh loading

This commit is contained in:
xmflsct 2023-02-02 14:15:37 +01:00
parent 2d9f7a90cc
commit 74badd94cb
2 changed files with 12 additions and 8 deletions

View File

@ -61,7 +61,7 @@ const TimelineRefresh: React.FC<Props> = ({
const prevStatusId = useRef<Mastodon.Status['id']>()
const queryClient = useQueryClient()
const { refetch } = useTimelineQuery({ ...queryKey[1] })
const { refetch, isFetched } = useTimelineQuery({ ...queryKey[1] })
const { t } = useTranslation('componentTimeline')
const { colors } = useTheme()
@ -118,10 +118,11 @@ const TimelineRefresh: React.FC<Props> = ({
}
},
data => {
if (data) {
if (data && isFetched) {
runOnJS(haptics)('Light')
}
}
},
[isFetched]
)
const fetchAndScrolled = useSharedValue(false)
@ -246,6 +247,8 @@ const TimelineRefresh: React.FC<Props> = ({
[]
)
if (!isFetched) return null
return (
<Animated.View
style={{

View File

@ -228,11 +228,12 @@ const Timeline: React.FC<Props> = ({
)
}
viewabilityConfigCallbackPairs={viewabilityConfigCallbackPairs.current}
{...(!isLoading && {
maintainVisibleContentPosition: {
minIndexForVisible: 0
}
})}
{...(!isLoading &&
!isFetching && {
maintainVisibleContentPosition: {
minIndexForVisible: 0
}
})}
{...androidRefreshControl}
{...customProps}
/>