Skip to content

Commit

Permalink
Fix calculation of photo credits count
Browse files Browse the repository at this point in the history
Using ++/-- it sometimes got it wrong (as it also got set to 0 on
page change), and was at 0 even when there was a photo credit.

This meant the photo credits were hidden when they shouldn't be.
  • Loading branch information
nicksellen committed May 22, 2020
1 parent 0b16cb7 commit 03f7aa3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modules/core/client/controllers/app.client.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,14 @@ function AppController(
*/
$scope.$on('photoCreditsUpdated', function (scope, photo) {
angular.extend(vm.photoCredits, photo);
vm.photoCreditsCount++;
vm.photoCreditsCount = Object.keys(vm.photoCredits).length;
});

$scope.$on('photoCreditsRemoved', function (scope, photo) {
const photoName = Object.keys(photo)[0];
// @TODO inconsistent results when there is the same photo displayed multiple times
delete vm.photoCredits[photoName];
vm.photoCreditsCount--;
vm.photoCreditsCount = Object.keys(vm.photoCredits).length;
});
}

Expand Down

0 comments on commit 03f7aa3

Please sign in to comment.