Commit 28509a30112fc885ab92ca443ec2520ec4930a71

Authored by Caio Almeida
1 parent aac3d3d9

not define lastCommentId is there is no comment

Showing 1 changed file with 3 additions and 1 deletions   Show diff stats
www/js/controllers.js
@@ -940,7 +940,9 @@ angular.module('confjuvapp.controllers', []) @@ -940,7 +940,9 @@ angular.module('confjuvapp.controllers', [])
940 $scope.loading = false; 940 $scope.loading = false;
941 var comments = resp.data.comments; 941 var comments = resp.data.comments;
942 $scope.proposal.comments = $scope.proposal.comments.concat(comments); 942 $scope.proposal.comments = $scope.proposal.comments.concat(comments);
943 - $scope.proposal.lastCommentId = comments[comments.length - 1].id; 943 + if(comments.length > 0){
  944 + $scope.proposal.lastCommentId = comments[comments.length - 1].id;
  945 + }
944 if ($scope.proposal.comments.length == 0) { 946 if ($scope.proposal.comments.length == 0) {
945 $scope.commentStatus = 'none'; 947 $scope.commentStatus = 'none';
946 $scope.proposal.comments = [{ body: '', skip: true, author: { name: '' }}]; 948 $scope.proposal.comments = [{ body: '', skip: true, author: { name: '' }}];