Commit 279252435487987f981b3cf1d89ed63269ee5444
1 parent
07cb7dcb
Exists in
master
and in
2 other branches
Ticket #56: Get full list of followed proposals
Showing
1 changed file
with
9 additions
and
6 deletions
Show diff stats
www/js/controllers.js
... | ... | @@ -1125,14 +1125,16 @@ angular.module('confjuvapp.controllers', []) |
1125 | 1125 | timeout: 10000 |
1126 | 1126 | }; |
1127 | 1127 | |
1128 | - $http.get(ConfJuvAppUtils.pathTo('/articles/followed_by_me?fields=id&private_token=' + $scope.token + '&_=' + new Date().getTime()), config) | |
1128 | + $http.get(ConfJuvAppUtils.pathTo('/articles/followed_by_me?private_token=' + $scope.token + '&_=' + new Date().getTime()), config) | |
1129 | 1129 | .then(function(resp) { |
1130 | - $scope.loading = false; | |
1131 | 1130 | $scope.following = []; |
1131 | + $scope.followingIds = []; | |
1132 | 1132 | var followed = resp.data.articles; |
1133 | 1133 | for (var i = 0; i < followed.length; i++) { |
1134 | - $scope.following.push(followed[i].id); | |
1134 | + $scope.following.push(followed[i]); | |
1135 | + $scope.followingIds.push(followed[i].id); | |
1135 | 1136 | } |
1137 | + $scope.loading = false; | |
1136 | 1138 | }, function(err) { |
1137 | 1139 | $scope.loading = false; |
1138 | 1140 | $ionicPopup.alert({ title: 'Propostas seguidas', template: 'Erro ao carregar propostas seguidas' }); |
... | ... | @@ -1140,8 +1142,8 @@ angular.module('confjuvapp.controllers', []) |
1140 | 1142 | }; |
1141 | 1143 | |
1142 | 1144 | $scope.isFollowing = function(proposal) { |
1143 | - if ($scope.hasOwnProperty('following')) { | |
1144 | - return ($scope.following.indexOf(proposal.id) > -1); | |
1145 | + if ($scope.hasOwnProperty('followingIds')) { | |
1146 | + return ($scope.followingIds.indexOf(proposal.id) > -1); | |
1145 | 1147 | } |
1146 | 1148 | else { |
1147 | 1149 | return false; |
... | ... | @@ -1161,7 +1163,8 @@ angular.module('confjuvapp.controllers', []) |
1161 | 1163 | $http.post(ConfJuvAppUtils.pathTo('articles/' + proposal.id + '/follow'), jQuery.param({ private_token: $scope.token }), config) |
1162 | 1164 | .then(function(resp) { |
1163 | 1165 | $ionicPopup.alert({ title: 'Seguir proposta', template: 'Pronto! Você pode acompanhar suas propostas seguidas através do menu lateral esquerdo.' }); |
1164 | - $scope.following.push(proposal.id); | |
1166 | + $scope.following.push(proposal); | |
1167 | + $scope.followingIds.push(proposal.id); | |
1165 | 1168 | $scope.loading = false; |
1166 | 1169 | }, function(err) { |
1167 | 1170 | $ionicPopup.alert({ title: 'Seguir proposta', template: 'Erro ao seguir proposta.' }); | ... | ... |