[Glitch] Shows loading state for gallery correctly

Port db54c59df4 to glitch-soc

Signed-off-by: Claire <claire.github-309c@sitedethib.com>
This commit is contained in:
Echo
2026-03-27 16:03:52 +01:00
committed by Claire
parent 9dfacc21f8
commit df5900d33c

View File

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