From 279252435487987f981b3cf1d89ed63269ee5444 Mon Sep 17 00:00:00 2001 From: Caio SBA Date: Sun, 30 Aug 2015 06:00:09 -0300 Subject: [PATCH] Ticket #56: Get full list of followed proposals --- www/js/controllers.js | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/www/js/controllers.js b/www/js/controllers.js index c5f9f2b..79259e9 100644 --- a/www/js/controllers.js +++ b/www/js/controllers.js @@ -1125,14 +1125,16 @@ angular.module('confjuvapp.controllers', []) timeout: 10000 }; - $http.get(ConfJuvAppUtils.pathTo('/articles/followed_by_me?fields=id&private_token=' + $scope.token + '&_=' + new Date().getTime()), config) + $http.get(ConfJuvAppUtils.pathTo('/articles/followed_by_me?private_token=' + $scope.token + '&_=' + new Date().getTime()), config) .then(function(resp) { - $scope.loading = false; $scope.following = []; + $scope.followingIds = []; var followed = resp.data.articles; for (var i = 0; i < followed.length; i++) { - $scope.following.push(followed[i].id); + $scope.following.push(followed[i]); + $scope.followingIds.push(followed[i].id); } + $scope.loading = false; }, function(err) { $scope.loading = false; $ionicPopup.alert({ title: 'Propostas seguidas', template: 'Erro ao carregar propostas seguidas' }); @@ -1140,8 +1142,8 @@ angular.module('confjuvapp.controllers', []) }; $scope.isFollowing = function(proposal) { - if ($scope.hasOwnProperty('following')) { - return ($scope.following.indexOf(proposal.id) > -1); + if ($scope.hasOwnProperty('followingIds')) { + return ($scope.followingIds.indexOf(proposal.id) > -1); } else { return false; @@ -1161,7 +1163,8 @@ angular.module('confjuvapp.controllers', []) $http.post(ConfJuvAppUtils.pathTo('articles/' + proposal.id + '/follow'), jQuery.param({ private_token: $scope.token }), config) .then(function(resp) { $ionicPopup.alert({ title: 'Seguir proposta', template: 'Pronto! Você pode acompanhar suas propostas seguidas através do menu lateral esquerdo.' }); - $scope.following.push(proposal.id); + $scope.following.push(proposal); + $scope.followingIds.push(proposal.id); $scope.loading = false; }, function(err) { $ionicPopup.alert({ title: 'Seguir proposta', template: 'Erro ao seguir proposta.' }); -- libgit2 0.21.2