mirror of
https://github.com/glitch-soc/mastodon.git
synced 2026-03-29 03:00:33 +02:00
[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:
@@ -41,15 +41,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) {
|
||||||
@@ -57,13 +67,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');
|
||||||
|
|
||||||
@@ -81,8 +91,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,
|
||||||
};
|
};
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
@@ -94,11 +104,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);
|
||||||
|
|
||||||
@@ -223,7 +233,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}
|
||||||
|
|||||||
Reference in New Issue
Block a user