Refine remote logic

When loading remote ancestors, the position might not be kept
This commit is contained in:
xmflsct 2023-03-14 21:28:41 +01:00
parent b5ddebe123
commit bfe37db9b6
1 changed files with 9 additions and 14 deletions

View File

@ -111,12 +111,13 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
}
)
flRef.current?.props.data?.length && setTimeout(() => {
flRef.current?.scrollToIndex({
index: ancestorsCache.current?.length || 0,
viewOffset: 50
})
}, 50)
flRef.current?.props.data?.length &&
setTimeout(() => {
flRef.current?.scrollToIndex({
index: ancestorsCache.current?.length || 0,
viewOffset: 50
})
}, 50)
break
}
}
@ -236,14 +237,8 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
return
}
if ((query.data?.pages[0].body.length || 0) <= data.length) {
if (
!hasRemoteContent &&
(query.data?.pages[0].body.length || 0) <= data.length &&
data.length > 1
) {
setHasRemoteContent(true)
}
if ((query.data?.pages[0].body.length || 0) < data.length) {
setHasRemoteContent(true)
queryClient.cancelQueries(queryKey.local)
queryClient.setQueryData<{ pages: { body: Mastodon.Status[] }[] }>(