Impliment check for leader object's existence in challenge search

This commit is contained in:
Blade Barringer
2015-06-13 20:50:32 -05:00
parent 703a2511da
commit 2134465a75

View File

@@ -282,7 +282,9 @@ habitrpg.controller("ChallengesCtrl", ['$rootScope','$scope', 'Shared', 'User',
};
function _shouldShowChallenge(chal) {
var userIsOwner = chal.leader._id == User.user.id;
// Have to check that the leader object exists first in the
// case where a challenge's leader deletes their account
var userIsOwner = (chal.leader && chal.leader._id) == User.user.id;
var groupSelected = $scope.search.group[chal.group._id];
var checkOwner = $scope.search._isOwner === 'either' || (userIsOwner === $scope.search._isOwner);