Make user sync after accepting or rejecting a quest

This commit is contained in:
Blade Barringer
2015-05-28 08:14:50 -05:00
parent dc8647d6ae
commit 42b482cb7e
3 changed files with 21 additions and 3 deletions

View File

@@ -501,6 +501,7 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
.controller("PartyCtrl", ['$rootScope','$scope', 'Groups', 'User', 'Challenges', '$state', '$compile', .controller("PartyCtrl", ['$rootScope','$scope', 'Groups', 'User', 'Challenges', '$state', '$compile',
function($rootScope,$scope, Groups, User, Challenges, $state, $compile) { function($rootScope,$scope, Groups, User, Challenges, $state, $compile) {
$scope.type = 'party'; $scope.type = 'party';
$scope.text = window.env.t('party'); $scope.text = window.env.t('party');
$scope.group = $rootScope.party = Groups.party(); $scope.group = $rootScope.party = Groups.party();
@@ -579,6 +580,23 @@ habitrpg.controller("GroupsCtrl", ['$scope', '$rootScope', 'Shared', 'Groups', '
$rootScope.party.$questAbort(); $rootScope.party.$questAbort();
} }
$scope.questAccept = function(party){
party.$questAccept()
.then(function(res) {
User.sync();
}, function(err) {
console.log(err);
});
}
$scope.questReject = function(party){
party.$questReject()
.then(function(res) {
User.sync();
}, function(err) {
console.log(err);
});
}
} }
]) ])

View File

@@ -150,7 +150,7 @@ habitrpg.controller('NotificationCtrl',
// Quest invitation modal // Quest invitation modal
$rootScope.$watch('user.party.quest.RSVPNeeded', function(after, before){ $rootScope.$watch('user.party.quest.RSVPNeeded', function(after, before){
if (after != true) return; if (after != true) return;
$rootScope.openModal('questInvitation'); $rootScope.openModal('questInvitation', {controller:'PartyCtrl'});
}); });
$rootScope.$on('responseError', function(ev, error){ $rootScope.$on('responseError', function(ev, error){

View File

@@ -87,5 +87,5 @@ script(type='text/ng-template', id='modals/questInvitation.html')
quest-rewards(key='{{::user.party.quest.key}}', header=env.t('rewards')) quest-rewards(key='{{::user.party.quest.key}}', header=env.t('rewards'))
.modal-footer .modal-footer
button.btn.btn-default(ng-click='questHold = true; $close()')=env.t('askLater') button.btn.btn-default(ng-click='questHold = true; $close()')=env.t('askLater')
button.btn.btn-default(ng-click='party.$questReject(); $close()')=env.t('reject') button.btn.btn-default(ng-click='questReject(party); $close()')=env.t('reject')
button.btn.btn-primary(ng-click='party.$questAccept(); $close()')=env.t('accept') button.btn.btn-primary(ng-click='questAccept(party); $close()')=env.t('accept')