pl-fe: fix timelines 'load more' behavior

Signed-off-by: Nicole Mikołajczyk <git@mkljczk.pl>
This commit is contained in:
Nicole Mikołajczyk
2025-05-04 00:05:18 +02:00
parent bd6e8e993e
commit 5dafac744d
3 changed files with 6 additions and 8 deletions

View File

@ -236,6 +236,7 @@ const fetchAccountTimeline = (accountId: string, { exclude_replies, pinned, only
if (pinned || only_media) params.with_muted = true;
if (useSettingsStore.getState().settings.autoTranslate) params.language = getLocale();
if (!expand && state.timelines[timelineId]?.loaded) return;
if (expand && state.timelines[timelineId]?.isLoading) return;
const fn = (expand && state.timelines[timelineId]?.next?.()) || getClient(state).accounts.getAccountStatuses(accountId, params);

View File

@ -29,7 +29,6 @@ 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) {
@ -60,7 +59,7 @@ const AccountGallery = () => {
};
useEffect(() => {
if (account && !afterInitialLoad) {
if (account) {
dispatch(fetchAccountTimeline(account.id, { only_media: true, limit: 40 }));
}
}, [account?.id]);

View File

@ -52,15 +52,13 @@ const AccountTimeline: React.FC<IAccountTimeline> = ({ params, withReplies = fal
.catch(() => setAccountLoading(false));
}, [params.username]);
useEffect(() => {
if (account && !withReplies) {
dispatch(fetchAccountTimeline(account.id, { pinned: true }));
}
}, [account?.id, withReplies]);
useEffect(() => {
if (account) {
dispatch(fetchAccountTimeline(account.id, { exclude_replies: !withReplies }));
if (!withReplies) {
dispatch(fetchAccountTimeline(account.id, { pinned: true }));
}
}
}, [account?.id, withReplies]);