From 7fbf5e4b859739553315d956b08b87bf689e722e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nicole=20Miko=C5=82ajczyk?= Date: Sat, 3 May 2025 21:08:59 +0200 Subject: [PATCH] pl-fe: timeline load more fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Nicole Mikołajczyk --- packages/pl-fe/src/features/account-gallery/index.tsx | 3 ++- packages/pl-fe/src/reducers/timelines.ts | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/packages/pl-fe/src/features/account-gallery/index.tsx b/packages/pl-fe/src/features/account-gallery/index.tsx index 6925548d9..fe4840ab7 100644 --- a/packages/pl-fe/src/features/account-gallery/index.tsx +++ b/packages/pl-fe/src/features/account-gallery/index.tsx @@ -29,6 +29,7 @@ const AccountGallery = () => { const attachments: Array = useAppSelector((state) => account ? getAccountGallery(state, account.id) : []); const isLoading = useAppSelector((state) => state.timelines[`account:${account?.id}:with_replies:media`]?.isLoading); const hasMore = useAppSelector((state) => state.timelines[`account:${account?.id}:with_replies:media`]?.hasMore); + const afterInitialLoad = useAppSelector((state) => state.timelines[`account:${account?.id}:with_replies:media`]?.loaded); const handleScrollToBottom = () => { if (hasMore) { @@ -59,7 +60,7 @@ const AccountGallery = () => { }; useEffect(() => { - if (account) { + if (account && !afterInitialLoad) { dispatch(fetchAccountTimeline(account.id, { only_media: true, limit: 40 })); } }, [account?.id]); diff --git a/packages/pl-fe/src/reducers/timelines.ts b/packages/pl-fe/src/reducers/timelines.ts index 1a403b84f..43e9d20f9 100644 --- a/packages/pl-fe/src/reducers/timelines.ts +++ b/packages/pl-fe/src/reducers/timelines.ts @@ -36,6 +36,7 @@ interface Timeline { totalQueuedItemsCount: number; //used for queuedItems overflow for MAX_QUEUED_ITEMS+ loadingFailed: boolean; isPartial: boolean; + loaded: boolean; } const newTimeline = (): Timeline => ({ @@ -50,6 +51,7 @@ const newTimeline = (): Timeline => ({ totalQueuedItemsCount: 0, //used for queuedItems overflow for MAX_QUEUED_ITEMS+ loadingFailed: false, isPartial: false, + loaded: false, }); const initialState: State = {}; @@ -105,6 +107,7 @@ const expandNormalizedTimeline = ( timeline.isPartial = isPartial; timeline.next = next; timeline.prev = prev; + timeline.loaded = true; if (!next && !isLoadingRecent) timeline.hasMore = false;