fixed preloading bug for sorting null branches

This commit is contained in:
Florian Scholdei
2019-03-29 14:54:18 +01:00
parent b7178d3332
commit e6912ef77b
2 changed files with 11 additions and 7 deletions

View File

@@ -40,9 +40,9 @@ type Props = {
// followed by develop the rest should be ordered by its name
export function orderBranches(branches: Branch[]) {
branches.sort((a, b) => {
if (a.defaultBranch && !b.defaultBranch ) {
if (a.defaultBranch && !b.defaultBranch) {
return -20;
} else if (!a.defaultBranch && b.defaultBranch ) {
} else if (!a.defaultBranch && b.defaultBranch) {
return 20;
} else if (a.name === "master" && b.name !== "master") {
return -10;
@@ -74,16 +74,16 @@ class BranchesOverview extends React.Component<Props> {
render() {
const { baseUrl, loading, error, branches, t } = this.props;
orderBranches(branches);
if (error) {
return <ErrorNotification error={error} />;
}
if (loading) {
if (!branches || loading) {
return <Loading />;
}
orderBranches(branches);
return (
<>
<Subtitle subtitle={t("branches.overview.title")} />