diff --git a/website/public/js/app.js b/website/public/js/app.js
index 5d685de42a..a128c2ce88 100644
--- a/website/public/js/app.js
+++ b/website/public/js/app.js
@@ -150,8 +150,8 @@ window.habitrpg = angular.module('habitrpg',
url: '/:gid',
templateUrl: 'partials/options.social.guilds.detail.html',
title: env.t('titleGuilds'),
- controller: ['$scope', 'Groups', 'Chat', '$stateParams', 'Members',
- function($scope, Groups, Chat, $stateParams, Members){
+ controller: ['$scope', 'Groups', 'Chat', '$stateParams', 'Members', 'Challenges',
+ function($scope, Groups, Chat, $stateParams, Members, Challenges){
Groups.Group.get($stateParams.gid)
.then(function (response) {
$scope.group = response.data.data;
@@ -164,6 +164,10 @@ window.habitrpg = angular.module('habitrpg',
.then(function (response) {
$scope.group.invites = response.data.data;
});
+ Challenges.getGroupChallenges($scope.group._id)
+ .then(function (response) {
+ $scope.group.challenges = response.data.data;
+ });
});
}]
})
diff --git a/website/public/js/controllers/groupsCtrl.js b/website/public/js/controllers/groupsCtrl.js
index da8016bee0..cafbe3b158 100644
--- a/website/public/js/controllers/groupsCtrl.js
+++ b/website/public/js/controllers/groupsCtrl.js
@@ -18,8 +18,7 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
// 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') {
- var guilds = Groups.myGuilds();
- return _.detect(guilds, function(g) { return g._id === group._id });
+ return _.detect(User.user.guilds, function(guildId) { return guildId === group._id });
}
// Similarly, if we're dealing with the user's current party, return true.
diff --git a/website/public/js/controllers/guildsCtrl.js b/website/public/js/controllers/guildsCtrl.js
index dfedbddc7c..6555495e7e 100644
--- a/website/public/js/controllers/guildsCtrl.js
+++ b/website/public/js/controllers/guildsCtrl.js
@@ -3,8 +3,8 @@
habitrpg.controller("GuildsCtrl", ['$scope', 'Groups', 'User', 'Challenges', '$rootScope', '$state', '$location', '$compile', 'Analytics',
function($scope, Groups, User, Challenges, $rootScope, $state, $location, $compile, Analytics) {
$scope.groups = {
- guilds: Groups.myGuilds(),
- public: Groups.publicGuilds(),
+ guilds: [],
+ public: [],
};
Groups.myGuilds()
@@ -88,8 +88,9 @@ habitrpg.controller("GuildsCtrl", ['$scope', 'Groups', 'User', 'Challenges', '$r
var html, title;
- Challenges.Challenge.query(function(challenges) {
- challenges = _.pluck(_.filter(challenges, function(c) {
+ Challenges.getGroupChallenges(group._id)
+ .then(function(response) {
+ var challenges = _.pluck(_.filter(response.data.data, function(c) {
return c.group._id == group._id;
}), '_id');
diff --git a/website/public/js/controllers/partyCtrl.js b/website/public/js/controllers/partyCtrl.js
index 64511ee13e..68623f0827 100644
--- a/website/public/js/controllers/partyCtrl.js
+++ b/website/public/js/controllers/partyCtrl.js
@@ -84,31 +84,32 @@ habitrpg.controller("PartyCtrl", ['$rootScope','$scope','Groups','Chat','User','
title = window.env.t('leavePartyCha');
//TODO: Move this to challenge service
- //@TODO: Implement this when we convert front-end challenge service
- // Challenges.Challenge.query(function(challenges) {
- // challenges = _.pluck(_.filter(challenges, function(c) {
- // return c.group._id == group._id;
- // }), '_id');
- // if (_.intersection(challenges, User.user.challenges).length > 0) {
- // html = $compile(
- // '' + window.env.t('removeTasks') + '
\n' + window.env.t('keepTasks') + '
\n' + window.env.t('cancel') + '
'
- // )($scope);
- // title = window.env.t('leavePartyCha');
- // } else {
- // html = $compile(
- // '' + window.env.t('confirm') + '
\n' + window.env.t('cancel') + '
'
- // )($scope);
- // title = window.env.t('leaveParty');
- // }
+ Challenges.getGroupChallenges(group._id)
+ .then(function(response) {
+ var challenges = _.pluck(_.filter(response.data.data, function(c) {
+ return c.group._id == group._id;
+ }), '_id');
- $scope.popoverEl.popover('destroy').popover({
- html: true,
- placement: 'top',
- trigger: 'manual',
- title: title,
- content: html
- }).popover('show');
- // });
+ if (_.intersection(challenges, User.user.challenges).length > 0) {
+ html = $compile(
+ '' + window.env.t('removeTasks') + '
\n' + window.env.t('keepTasks') + '
\n' + window.env.t('cancel') + '
'
+ )($scope);
+ title = window.env.t('leavePartyCha');
+ } else {
+ html = $compile(
+ '' + window.env.t('confirm') + '
\n' + window.env.t('cancel') + '
'
+ )($scope);
+ title = window.env.t('leaveParty');
+ }
+
+ $scope.popoverEl.popover('destroy').popover({
+ html: true,
+ placement: 'top',
+ trigger: 'manual',
+ title: title,
+ content: html
+ }).popover('show');
+ });
};
$scope.clickStartQuest = function () {
diff --git a/website/public/js/services/chatServices.js b/website/public/js/services/chatServices.js
index e7bb663c8e..ed812e08ad 100644
--- a/website/public/js/services/chatServices.js
+++ b/website/public/js/services/chatServices.js
@@ -63,7 +63,7 @@ angular.module('habitrpg')
}
function markChatSeen (groupId) {
- if (User.user.newMessages) delete User.user.newMessages[gid];
+ if (User.user.newMessages) delete User.user.newMessages[groupId];
return $http({
method: 'POST',
url: apiV3Prefix + '/groups/' + groupId + '/chat/seen',