From 959f9d81da4978b20333d842b1cbb01310a16038 Mon Sep 17 00:00:00 2001 From: Sebastian Sdorra Date: Wed, 17 Oct 2018 15:18:42 +0200 Subject: [PATCH] fix duplicate loading of changesets on first page load --- scm-ui/src/repos/modules/branches.js | 4 +--- scm-ui/src/repos/modules/branches.test.js | 5 +++++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/scm-ui/src/repos/modules/branches.js b/scm-ui/src/repos/modules/branches.js index 6b19337278..f819b07700 100644 --- a/scm-ui/src/repos/modules/branches.js +++ b/scm-ui/src/repos/modules/branches.js @@ -97,14 +97,12 @@ function extractBranchesFromPayload(payload: any) { // Selectors -const empty = []; - export function getBranches(state: Object, repository: Repository) { const key = createKey(repository); if (state.branches[key]) { return state.branches[key]; } - return empty; + return null; } export function getBranch( diff --git a/scm-ui/src/repos/modules/branches.test.js b/scm-ui/src/repos/modules/branches.test.js index 4d45a24a09..bcbae28611 100644 --- a/scm-ui/src/repos/modules/branches.test.js +++ b/scm-ui/src/repos/modules/branches.test.js @@ -157,6 +157,11 @@ describe("branches", () => { expect(one).toBe(two); }); + it("should return null, if no branches for the repository available", () => { + const branches = getBranches({ branches: {} }, repository); + expect(branches).toBeNull(); + }); + it("should return single branch by name", () => { const branch = getBranch(state, repository, "branch1"); expect(branch).toEqual(branch1);