Shows loading state for gallery correctly (#38451)

This commit is contained in:
Echo
2026-03-27 16:03:52 +01:00
committed by GitHub
parent a8c08dfeb3
commit db54c59df4

View File

@@ -37,15 +37,25 @@ const selectGalleryTimeline = createAppSelector(
(state) => state.statuses, (state) => state.statuses,
], ],
(accountId, timelines, accounts, statuses) => { (accountId, timelines, accounts, statuses) => {
let items = emptyList;
if (!accountId) { if (!accountId) {
return null; return {
items,
hasMore: false,
isLoading: false,
withReplies: false,
};
} }
const account = accounts.get(accountId); const account = accounts.get(accountId);
if (!account) { if (!account) {
return null; return {
items,
hasMore: false,
isLoading: false,
withReplies: false,
};
} }
let items = emptyList;
const { show_media, show_media_replies } = account; const { show_media, show_media_replies } = account;
// If the account disabled showing media, don't display anything. // If the account disabled showing media, don't display anything.
if (!show_media && redesignEnabled) { if (!show_media && redesignEnabled) {
@@ -53,13 +63,13 @@ const selectGalleryTimeline = createAppSelector(
items, items,
hasMore: false, hasMore: false,
isLoading: false, isLoading: false,
showingReplies: false, withReplies: false,
}; };
} }
const showingReplies = show_media_replies && redesignEnabled; const withReplies = show_media_replies && redesignEnabled;
const timeline = timelines.get( const timeline = timelines.get(
`account:${accountId}:media${showingReplies ? ':with_replies' : ''}`, `account:${accountId}:media${withReplies ? ':with_replies' : ''}`,
); );
const statusIds = timeline?.get('items'); const statusIds = timeline?.get('items');
@@ -77,8 +87,8 @@ const selectGalleryTimeline = createAppSelector(
return { return {
items, items,
hasMore: !!timeline?.get('hasMore'), hasMore: !!timeline?.get('hasMore'),
isLoading: !!timeline?.get('isLoading'), isLoading: timeline?.get('isLoading') ? true : false,
showingReplies, withReplies,
}; };
}, },
); );
@@ -89,11 +99,11 @@ export const AccountGallery: React.FC<{
const dispatch = useAppDispatch(); const dispatch = useAppDispatch();
const accountId = useAccountId(); const accountId = useAccountId();
const { const {
isLoading = true, isLoading,
hasMore = false, items: attachments,
items: attachments = emptyList, hasMore,
showingReplies: withReplies = false, withReplies,
} = useAppSelector((state) => selectGalleryTimeline(state, accountId)) ?? {}; } = useAppSelector((state) => selectGalleryTimeline(state, accountId));
const { suspended, blockedBy, hidden } = useAccountVisibility(accountId); const { suspended, blockedBy, hidden } = useAccountVisibility(accountId);
@@ -215,7 +225,7 @@ export const AccountGallery: React.FC<{
alwaysPrepend alwaysPrepend
append={accountId && <RemoteHint accountId={accountId} />} append={accountId && <RemoteHint accountId={accountId} />}
scrollKey='account_gallery' scrollKey='account_gallery'
isLoading={isLoading} showLoading={isLoading}
hasMore={!forceEmptyState && hasMore} hasMore={!forceEmptyState && hasMore}
onLoadMore={handleLoadMore} onLoadMore={handleLoadMore}
emptyMessage={emptyMessage} emptyMessage={emptyMessage}