From 2ff211ce2ccca164d9ae670b85231ba88be61f78 Mon Sep 17 00:00:00 2001 From: Shane Kilkelly Date: Mon, 7 Nov 2016 14:36:04 +0000 Subject: [PATCH] Make sure the `$scope.canAddCollaborators` var is initialised at least once, outside of angular `$watch`. --- .../controllers/ShareProjectModalController.coffee | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/services/web/public/coffee/ide/share/controllers/ShareProjectModalController.coffee b/services/web/public/coffee/ide/share/controllers/ShareProjectModalController.coffee index 6f95d4e38f..2d27f96970 100644 --- a/services/web/public/coffee/ide/share/controllers/ShareProjectModalController.coffee +++ b/services/web/public/coffee/ide/share/controllers/ShareProjectModalController.coffee @@ -19,11 +19,16 @@ define [ , 200 INFINITE_COLLABORATORS = -1 - $scope.$watch "(project.members.length + project.invites.length)", (noOfMembers) -> - allowedNoOfMembers = $scope.project.features.collaborators - $scope.canAddCollaborators = noOfMembers < allowedNoOfMembers or allowedNoOfMembers == INFINITE_COLLABORATORS - window._m = projectMembers + $scope.refreshCanAddCollaborators = () -> + allowedNoOfMembers = $scope.project.features.collaborators + $scope.canAddCollaborators = ( + ($scope.project.members.length + $scope.project.invites.length) < allowedNoOfMembers or allowedNoOfMembers == INFINITE_COLLABORATORS + ) + $scope.refreshCanAddCollaborators() + + $scope.$watch "(project.members.length + project.invites.length)", (_noOfMembers) -> + $scope.refreshCanAddCollaborators() $scope.autocompleteContacts = [] do loadAutocompleteUsers = () ->