mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-19 15:48:04 +01:00
Added force sync param to party and tavern requests
This commit is contained in:
@@ -48,12 +48,15 @@ describe("Party Controller", function() {
|
|||||||
inject(function(_$state_) {
|
inject(function(_$state_) {
|
||||||
var state = _$state_;
|
var state = _$state_;
|
||||||
sandbox.stub(state, 'is').returns(true);
|
sandbox.stub(state, 'is').returns(true);
|
||||||
|
|
||||||
var syncParty = sinon.stub(groups.Group, 'syncParty')
|
var syncParty = sinon.stub(groups.Group, 'syncParty')
|
||||||
syncParty.returns(Promise.resolve(groupResponse));
|
syncParty.returns(Promise.resolve(groupResponse));
|
||||||
|
|
||||||
|
var froceSyncParty = sinon.stub(groups, 'party')
|
||||||
|
froceSyncParty.returns(Promise.resolve(groupResponse));
|
||||||
|
|
||||||
$controller('PartyCtrl', { $scope: scope, $state: state, User: User });
|
$controller('PartyCtrl', { $scope: scope, $state: state, User: User });
|
||||||
// @TODO: I have update the party ctrl to sync the user whenever it is called rather than only on the party page
|
expect(state.is).to.be.calledOnce;
|
||||||
// Since I have cached the promise, this should not be a performance issue, but let's keep this test here in case anything breaks.
|
|
||||||
// expect(state.is).to.be.calledOnce; // ensure initialization worked as desired
|
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -11,13 +11,20 @@ habitrpg.controller("PartyCtrl", ['$rootScope','$scope','Groups','Chat','User','
|
|||||||
$scope.inviteOrStartParty = Groups.inviteOrStartParty;
|
$scope.inviteOrStartParty = Groups.inviteOrStartParty;
|
||||||
$scope.loadWidgets = Social.loadWidgets;
|
$scope.loadWidgets = Social.loadWidgets;
|
||||||
|
|
||||||
Groups.Group.syncParty()
|
function handlePartyResponse (group) {
|
||||||
.then(function successCallback(group) {
|
$rootScope.party = $scope.group = group;
|
||||||
$rootScope.party = $scope.group = group;
|
checkForNotifications();
|
||||||
checkForNotifications();
|
}
|
||||||
}, function errorCallback(response) {
|
|
||||||
$rootScope.party = $scope.group = $scope.newGroup = { type: 'party' };
|
function handlePartyError (response) {
|
||||||
});
|
$rootScope.party = $scope.group = $scope.newGroup = { type: 'party' };
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($state.is('options.social.party')) {
|
||||||
|
Groups.party(true).then(handlePartyResponse, handlePartyError);
|
||||||
|
} else {
|
||||||
|
Groups.Group.syncParty().then(handlePartyResponse, handlePartyError);
|
||||||
|
}
|
||||||
|
|
||||||
function checkForNotifications () {
|
function checkForNotifications () {
|
||||||
// Checks if user's party has reached 2 players for the first time.
|
// Checks if user's party has reached 2 players for the first time.
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
habitrpg.controller("TavernCtrl", ['$scope', 'Groups', 'User', 'Challenges',
|
habitrpg.controller("TavernCtrl", ['$scope', 'Groups', 'User', 'Challenges',
|
||||||
function($scope, Groups, User, Challenges) {
|
function($scope, Groups, User, Challenges) {
|
||||||
Groups.tavern()
|
Groups.tavern(true)
|
||||||
.then(function (tavern) {
|
.then(function (tavern) {
|
||||||
$scope.group = tavern;
|
$scope.group = tavern;
|
||||||
Challenges.getGroupChallenges($scope.group._id)
|
Challenges.getGroupChallenges($scope.group._id)
|
||||||
|
|||||||
Reference in New Issue
Block a user