From 8f61f49826dd019fd96fc3f27b8d419d774c52bb Mon Sep 17 00:00:00 2001 From: Lisa P Date: Mon, 12 Oct 2015 18:31:23 +0200 Subject: [PATCH] query for more branches if first call is not last page --- app/routes/branches.coffee | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/app/routes/branches.coffee b/app/routes/branches.coffee index 45c75b41..42d422b2 100644 --- a/app/routes/branches.coffee +++ b/app/routes/branches.coffee @@ -8,12 +8,21 @@ Route = TravisRoute.extend apiEndpoint = config.apiEndpoint repoId = @modelFor('repo').get('id') + allTheBranches = Ember.ArrayProxy.create() + options = {} if @get('auth.signedIn') options.headers = { Authorization: "token #{@auth.token()}" } $.ajax("#{apiEndpoint}/v3/repo/#{repoId}/branches?include=build.commit&limit=100", options).then (response) -> - response.branches + allTheBranches = response.branches + unless response['@pagination'].is_last + $.ajax("#{apiEndpoint}/v3/repo/#{repoId}/branches?include=build.commit&limit=100&offset=1", options).then (response) -> + allTheBranches = allTheBranches.concat(response.branches) + allTheBranches + else + allTheBranches + activate: () -> $('.tab.tabs--main li').removeClass('active')