pl-fe: fix timelines 'load more' behavior
Signed-off-by: Nicole Mikołajczyk <git@mkljczk.pl>
This commit is contained in:
@ -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);
|
||||
|
||||
@ -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]);
|
||||
|
||||
@ -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]);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user