mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 09:25:43 +01:00
fix re-render bug for changesets
This commit is contained in:
@@ -3,6 +3,7 @@ import { apiClient, urls } from "@scm-manager/ui-components";
|
||||
import { isPending } from "../../modules/pending";
|
||||
import { getFailure } from "../../modules/failure";
|
||||
import { Action, Branch, PagedCollection, Repository } from "@scm-manager/ui-types";
|
||||
import memoizeOne from "memoize-one";
|
||||
|
||||
export const FETCH_CHANGESETS = "scm/repos/FETCH_CHANGESETS";
|
||||
export const FETCH_CHANGESETS_PENDING = `${FETCH_CHANGESETS}_${PENDING_SUFFIX}`;
|
||||
@@ -254,10 +255,15 @@ export function getChangesets(state: object, repository: Repository, branch?: Br
|
||||
return null;
|
||||
}
|
||||
|
||||
return collectChangesets(stateRoot, changesets);
|
||||
}
|
||||
const mapChangesets = (stateRoot, changesets) => {
|
||||
return changesets.entries.map((id: string) => {
|
||||
return stateRoot.byId[id];
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
const collectChangesets = memoizeOne(mapChangesets);
|
||||
|
||||
export function getChangeset(state: object, repository: Repository, id: string) {
|
||||
const key = createItemId(repository);
|
||||
@@ -291,6 +297,8 @@ export function getFetchChangesetsFailure(state: object, repository: Repository,
|
||||
return getFailure(state, FETCH_CHANGESETS, createItemId(repository, branch));
|
||||
}
|
||||
|
||||
const EMPTY = {};
|
||||
|
||||
const selectList = (state: object, repository: Repository, branch?: Branch) => {
|
||||
const repoId = createItemId(repository);
|
||||
|
||||
@@ -302,7 +310,7 @@ const selectList = (state: object, repository: Repository, branch?: Branch) => {
|
||||
return repoState.byBranch[branchName];
|
||||
}
|
||||
}
|
||||
return {};
|
||||
return EMPTY;
|
||||
};
|
||||
|
||||
const selectListEntry = (state: object, repository: Repository, branch?: Branch): object => {
|
||||
@@ -310,7 +318,7 @@ const selectListEntry = (state: object, repository: Repository, branch?: Branch)
|
||||
if (list.entry) {
|
||||
return list.entry;
|
||||
}
|
||||
return {};
|
||||
return EMPTY;
|
||||
};
|
||||
|
||||
export const selectListAsCollection = (state: object, repository: Repository, branch?: Branch): PagedCollection => {
|
||||
|
||||
Reference in New Issue
Block a user