Simplify getAccountGallery selector, also fix getGroupGallery
This commit is contained in:
parent
1f653b1065
commit
2657c8f946
1 changed files with 4 additions and 11 deletions
|
@ -208,10 +208,8 @@ 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) => {
|
||||
|
||||
(state: RootState) => state.statuses,
|
||||
], (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());
|
||||
});
|
||||
|
||||
|
|
Loading…
Reference in a new issue