@@ -7,6 +7,8 @@ app.directive('post', function (LocalStorage, ApiService, $uibModal, $location)
77 templateUrl : 'directives/postView.html' ,
88 controller : function ( $scope ) {
99
10+ $scope . commentLoading = false ;
11+ $scope . voteLoading = false ;
1012 $scope . showMessages = false ;
1113 $scope . page = 1 ;
1214
@@ -68,7 +70,7 @@ app.directive('post', function (LocalStorage, ApiService, $uibModal, $location)
6870 showSignInRequiredModal ( ) ;
6971 return ;
7072 }
71-
73+ $scope . voteLoading = true ;
7274 ApiService . upvote ( usr . id , photo . id ) . then ( function ( resp ) {
7375 // If this is the first vote from this user then increase the number of total votes.
7476 if ( ! photo . downvote && ! photo . upvote ) {
@@ -85,9 +87,10 @@ app.directive('post', function (LocalStorage, ApiService, $uibModal, $location)
8587 // Let angular know which button to show on page
8688 photo . downvote = false ;
8789 photo . upvote = true ;
88-
90+ $scope . voteLoading = false ;
8991 } , function ( error ) {
9092 console . error ( error ) ;
93+ $scope . voteLoading = false ;
9194 } ) ;
9295
9396 } ;
@@ -103,7 +106,7 @@ app.directive('post', function (LocalStorage, ApiService, $uibModal, $location)
103106 showSignInRequiredModal ( ) ;
104107 return ;
105108 }
106-
109+ $scope . voteLoading = true ;
107110 ApiService . downvote ( usr . id , photo . id ) . then ( function ( resp ) {
108111 // If this is the first vote from this user then increase the number of total votes.
109112 if ( ! photo . downvote && ! photo . upvote ) {
@@ -120,9 +123,10 @@ app.directive('post', function (LocalStorage, ApiService, $uibModal, $location)
120123 // Let angular know which button to show on page
121124 photo . upvote = false ;
122125 photo . downvote = true ;
123-
126+ $scope . voteLoading = false ;
124127 } , function ( error ) {
125128 console . error ( error ) ;
129+ $scope . voteLoading = false ;
126130 } ) ;
127131 } ;
128132
@@ -132,7 +136,7 @@ app.directive('post', function (LocalStorage, ApiService, $uibModal, $location)
132136 showSignInRequiredModal ( ) ;
133137 return ;
134138 }
135-
139+ $scope . commentLoading = true ;
136140 ApiService . comment ( usr . id , photo . id , $scope . comment_text ) . then (
137141 function ( response ) {
138142 console . info ( response ) ;
@@ -141,9 +145,11 @@ app.directive('post', function (LocalStorage, ApiService, $uibModal, $location)
141145 if ( $scope . photo && $scope . photo . comments ) {
142146 $scope . photo . comments . push ( response ) ;
143147 }
148+ $scope . commentLoading = false ;
144149 } ,
145150 function ( error ) {
146151 console . error ( error ) ;
152+ $scope . commentLoading = false ;
147153 }
148154 ) ;
149155 }
0 commit comments