From 23a8c03be283aeec6a3f883cc4dec00d04f8154e Mon Sep 17 00:00:00 2001 From: xmflsct Date: Sat, 7 Jan 2023 12:15:07 +0100 Subject: [PATCH] Fix when there is no newer content --- src/components/Timeline/Refresh.tsx | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/src/components/Timeline/Refresh.tsx b/src/components/Timeline/Refresh.tsx index eaf86140..5a94e0fc 100644 --- a/src/components/Timeline/Refresh.tsx +++ b/src/components/Timeline/Refresh.tsx @@ -143,6 +143,8 @@ const TimelineRefresh: React.FC = ({ meta: {} }) .then(res => { + if (!res.body.length) return + queryClient.setQueryData< InfiniteData< PagedResponse<(Mastodon.Status | Mastodon.Notification | Mastodon.Conversation)[]> @@ -160,6 +162,11 @@ const TimelineRefresh: React.FC = ({ return res.body.length - PREV_PER_BATCH }) .then(async nextLength => { + if (!nextLength) { + prevActive.current = false + return + } + for (let [index] of Array(Math.ceil(nextLength / PREV_PER_BATCH)).entries()) { if (!fetchAndScrolled.value && index < 3 && scrollY.value > 15) { fetchAndScrolled.value = true @@ -194,6 +201,7 @@ const TimelineRefresh: React.FC = ({ } prevActive.current = false }) + .catch(err => console.warn(err)) } const runFetchLatest = async () => {