Join/Leave buttons on guild detail page. Addresses #4427

This commit is contained in:
Kevin Gisi
2015-04-15 06:13:54 -04:00
parent c19ec1387a
commit d455666650
4 changed files with 21 additions and 2 deletions

View File

@@ -16,6 +16,15 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
}
$scope.isMemberOfGroup = function(userid, group){
// If the group is a guild, just check for an intersection with the
// current user's guilds, rather than checking the members of the group.
if(group.type === 'guild') {
if (_.detect(Groups.myGuilds(), function(g) { return g._id === group._id })) {
return true;
}
}
if (!group.members) return false;
var memberIds = _.map(group.members, function(x){return x._id});
return ~(memberIds.indexOf(userid));