pl-fe: timeline load more fix

Signed-off-by: Nicole Mikołajczyk <git@mkljczk.pl>
This commit is contained in:
Nicole Mikołajczyk
2025-05-03 21:08:59 +02:00
parent e350c616b8
commit 7fbf5e4b85
2 changed files with 5 additions and 1 deletions

View File

@ -29,6 +29,7 @@ const AccountGallery = () => {
const attachments: Array<AccountGalleryAttachment> = 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]);

View File

@ -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;