Simplify getAccountGallery selector, also fix getGroupGallery

This commit is contained in:
Alex Gleason 2023-06-23 11:45:12 -05:00
parent 1f653b1065
commit 2657c8f946
No known key found for this signature in database
GPG key ID: 7211D1F99744FBB7

View file

@ -209,9 +209,7 @@ export const makeGetNotification = () => {
export const getAccountGallery = createSelector([
(state: RootState, id: string) => state.timelines.get(`account:${id}:media`)?.items || ImmutableOrderedSet<string>(),
(state: RootState) => state.statuses,
(state: RootState) => state.accounts,
], (statusIds, statuses, accounts) => {
], (statusIds, statuses) => {
return statusIds.reduce((medias: ImmutableList<any>, statusId: string) => {
const status = statuses.get(statusId);
if (!status) return medias;
@ -225,19 +223,14 @@ export const getAccountGallery = createSelector([
export const getGroupGallery = createSelector([
(state: RootState, id: string) => state.timelines.get(`group:${id}:media`)?.items || ImmutableOrderedSet<string>(),
(state: RootState) => state.statuses,
(state: RootState) => state.accounts,
], (statusIds, statuses, accounts) => {
], (statusIds, statuses) => {
return statusIds.reduce((medias: ImmutableList<any>, statusId: string) => {
const status = statuses.get(statusId);
if (!status) return medias;
if (status.reblog) return medias;
if (typeof status.account !== 'string') return medias;
const account = accounts.get(status.account);
return medias.concat(
status.media_attachments.map(media => media.merge({ status, account })));
status.media_attachments.map(media => media.merge({ status, account: status.account })));
}, ImmutableList());
});