mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-03 12:40:00 +00:00
Updated party query and create
This commit is contained in:
parent
679d56bc5c
commit
ee948f2447
5 changed files with 26 additions and 27 deletions
|
|
@ -24,7 +24,7 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
|
|||
|
||||
// Similarly, if we're dealing with the user's current party, return true.
|
||||
if(group.type === 'party') {
|
||||
var currentParty = Groups.party();
|
||||
var currentParty = group;
|
||||
if(currentParty._id && currentParty._id === group._id) return true;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -8,15 +8,19 @@ habitrpg.controller("HeaderCtrl", ['$scope', 'Groups', 'User',
|
|||
|
||||
$scope.inviteOrStartParty = Groups.inviteOrStartParty;
|
||||
|
||||
$scope.party = Groups.party(function(){
|
||||
var triggerResort = function() {
|
||||
$scope.partyMinusSelf = resortParty();
|
||||
};
|
||||
function handlePartyResponse (party) {
|
||||
$scope.party = party;
|
||||
|
||||
triggerResort();
|
||||
$scope.$watch('user.party.order', triggerResort);
|
||||
$scope.$watch('user.party.orderAscending', triggerResort);
|
||||
});
|
||||
var triggerResort = function() {
|
||||
$scope.partyMinusSelf = resortParty();
|
||||
};
|
||||
|
||||
triggerResort();
|
||||
$scope.$watch('user.party.order', triggerResort);
|
||||
$scope.$watch('user.party.orderAscending', triggerResort);
|
||||
}
|
||||
|
||||
Groups.party().then(handlePartyResponse, handlePartyResponse);
|
||||
|
||||
function resortParty() {
|
||||
var result = _.sortBy(
|
||||
|
|
|
|||
|
|
@ -8,15 +8,6 @@ habitrpg.controller("PartyCtrl", ['$rootScope','$scope','Groups','Chat','User','
|
|||
$scope.type = 'party';
|
||||
$scope.text = window.env.t('party');
|
||||
|
||||
//@TODO: cache
|
||||
Groups.Group.syncParty()
|
||||
.then(function successCallback(response) {
|
||||
$scope.group = response.data.data;
|
||||
checkForNotifications();
|
||||
}, function errorCallback(response) {
|
||||
$scope.newGroup = $scope.group = { type: 'party' };
|
||||
});
|
||||
|
||||
$scope.inviteOrStartParty = Groups.inviteOrStartParty;
|
||||
$scope.loadWidgets = Social.loadWidgets;
|
||||
|
||||
|
|
@ -52,11 +43,12 @@ habitrpg.controller("PartyCtrl", ['$rootScope','$scope','Groups','Chat','User','
|
|||
|
||||
$scope.create = function(group) {
|
||||
if (!group.name) group.name = env.t('possessiveParty', {name: User.user.profile.name});
|
||||
Groups.Group.create(group, function() {
|
||||
Analytics.track({'hitType':'event', 'eventCategory':'behavior', 'eventAction':'join group', 'owner':true, 'groupType':'party', 'privacy':'private'});
|
||||
Analytics.updateUser({'party.id': group.id, 'partySize': 1});
|
||||
$rootScope.hardRedirect('/#/options/groups/party');
|
||||
});
|
||||
Groups.Group.create(group)
|
||||
.then(function(response) {
|
||||
Analytics.track({'hitType':'event', 'eventCategory':'behavior', 'eventAction':'join group', 'owner':true, 'groupType':'party', 'privacy':'private'});
|
||||
Analytics.updateUser({'party.id': group.id, 'partySize': 1});
|
||||
$rootScope.hardRedirect('/#/options/groups/party');
|
||||
});
|
||||
};
|
||||
|
||||
$scope.join = function (party) {
|
||||
|
|
|
|||
|
|
@ -277,9 +277,11 @@ habitrpg.controller("RootCtrl", ['$scope', '$rootScope', '$location', 'User', '$
|
|||
if (spell.target == 'self') {
|
||||
$scope.castEnd(null, 'self');
|
||||
} else if (spell.target == 'party') {
|
||||
var party = Groups.party();
|
||||
party = (_.isArray(party) ? party : []).concat(User.user);
|
||||
$scope.castEnd(party, 'party');
|
||||
Groups.party()
|
||||
.then(function (party) {
|
||||
party = (_.isArray(party) ? party : []).concat(User.user);
|
||||
$scope.castEnd(party, 'party');
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -110,7 +110,8 @@ angular.module('habitrpg')
|
|||
data.party = response.data.data;
|
||||
deferred.resolve(data.party);
|
||||
}, function (response) {
|
||||
deferred.reject(response);
|
||||
data.party = { type: 'party' };
|
||||
deferred.reject(data.party);
|
||||
});
|
||||
} else {
|
||||
deferred.resolve(data.party);
|
||||
|
|
|
|||
Loading…
Reference in a new issue