Delay prepending to make sure it works

This commit is contained in:
xmflsct 2023-04-18 22:29:05 +02:00
parent 5b670f5d13
commit 21200a7758
1 changed files with 5 additions and 5 deletions

View File

@ -77,6 +77,8 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
const ancestorsCache = useRef<(Mastodon.Status & { _level?: number })[]>()
const loaded = useRef<boolean>(false)
const prependContent = async () => {
await new Promise<void>(promise => setTimeout(promise, 128))
loaded.current = true
if (ancestorsCache.current?.length) {
@ -173,14 +175,14 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
enabled: !toot._remote,
staleTime: 0,
refetchOnMount: true,
onSuccess: async data => {
onSuccess: data => {
if (data.pages[0].body.length < 1) {
navigation.goBack()
return
}
if (!remoteQueryEnabled) {
await prependContent()
prependContent()
}
}
}
@ -295,9 +297,7 @@ const TabSharedToot: React.FC<TabSharedStackScreenProps<'Tab-Shared-Toot'>> = ({
)
}
},
onSettled: async () => {
await prependContent()
}
onSettled: () => prependContent()
}
)