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