diff --git a/test/spec/controllers/partyCtrlSpec.js b/test/spec/controllers/partyCtrlSpec.js index 6dd9714531..00d3e676c5 100644 --- a/test/spec/controllers/partyCtrlSpec.js +++ b/test/spec/controllers/partyCtrlSpec.js @@ -51,7 +51,9 @@ describe("Party Controller", function() { var syncParty = sinon.stub(groups.Group, 'syncParty') syncParty.returns(Promise.resolve(groupResponse)); $controller('PartyCtrl', { $scope: scope, $state: state, User: User }); - expect(state.is).to.be.calledOnce; // ensure initialization worked as desired + // @TODO: I have update the party ctrl to sync the user whenever it is called rather than only on the party page + // 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 }); }; diff --git a/website/client/js/controllers/notificationCtrl.js b/website/client/js/controllers/notificationCtrl.js index f4a9aa613e..16a2c3a991 100644 --- a/website/client/js/controllers/notificationCtrl.js +++ b/website/client/js/controllers/notificationCtrl.js @@ -68,7 +68,7 @@ habitrpg.controller('NotificationCtrl', } $rootScope.$watch('user.stats.lvl', function(after, before) { - if (after <= before) return; + if (after <= before) return; Notification.lvl(); $rootScope.playSound('Level_Up'); if (User.user._tmp && User.user._tmp.drop && (User.user._tmp.drop.type === 'Quest')) return; @@ -127,7 +127,7 @@ habitrpg.controller('NotificationCtrl', Notification.drop(env.t('messageDropFood', {dropArticle: after.article, dropText: text, dropNotes: notes}), after); } else if (after.type === 'Quest') { $rootScope.selectedQuest = Content.quests[after.key]; - $rootScope.openModal('questDrop', {controller:'PartyCtrl',size:'sm'}); + $rootScope.openModal('questDrop', {controller:'PartyCtrl', size:'sm'}); } else if (after.notificationType === 'Mystery') { text = Content.gear.flat[after.key].text(); Notification.drop(env.t('messageDropMysteryItem', {dropText: text}), after); diff --git a/website/client/js/controllers/partyCtrl.js b/website/client/js/controllers/partyCtrl.js index 0049ff9815..64070734bf 100644 --- a/website/client/js/controllers/partyCtrl.js +++ b/website/client/js/controllers/partyCtrl.js @@ -11,15 +11,13 @@ habitrpg.controller("PartyCtrl", ['$rootScope','$scope','Groups','Chat','User',' $scope.inviteOrStartParty = Groups.inviteOrStartParty; $scope.loadWidgets = Social.loadWidgets; - if ($state.is('options.social.party')) { - Groups.Group.syncParty() - .then(function successCallback(group) { - $rootScope.party = $scope.group = group; - checkForNotifications(); - }, function errorCallback(response) { - $rootScope.party = $scope.group = $scope.newGroup = { type: 'party' }; - }); - } + Groups.Group.syncParty() + .then(function successCallback(group) { + $rootScope.party = $scope.group = group; + checkForNotifications(); + }, function errorCallback(response) { + $rootScope.party = $scope.group = $scope.newGroup = { type: 'party' }; + }); function checkForNotifications () { // Checks if user's party has reached 2 players for the first time. @@ -148,6 +146,15 @@ habitrpg.controller("PartyCtrl", ['$rootScope','$scope','Groups','Chat','User',' User.set({'invitations.party':{}}); } + $scope.questInit = function() { + var key = $rootScope.selectedQuest.key; + + Quests.initQuest(key).then(function() { + $rootScope.selectedQuest = undefined; + $scope.$close(); + }); + }; + $scope.questCancel = function(){ if (!confirm(window.env.t('sureCancel'))) return; diff --git a/website/views/shared/modals/quests.jade b/website/views/shared/modals/quests.jade index 10ce712b6a..40efa3b5c4 100644 --- a/website/views/shared/modals/quests.jade +++ b/website/views/shared/modals/quests.jade @@ -104,7 +104,8 @@ script(type='text/ng-template', id='modals/questDrop.html') .quest-icon(class='inventory_quest_scroll_{{::selectedQuest.key}}') h4!=env.t('leveledUpReceivedQuest', {level:'{{user.stats.lvl}}'}) .row(style='margin-top:2em') - button.btn.btn-primary(ng-click='inviteOrStartParty(group); $close()', ng-if='!party.members')=env.t('startAParty') + button.btn.btn-primary(ng-click='inviteOrStartParty(party); $close()', ng-if='!User.user.party._id')=env.t('startAParty') + button.btn.btn-primary(ng-click='inviteOrStartParty(party); $close()', ng-if='!User.user.party._id && !party.members')=env.t('battleWithFriends') button.btn.btn-primary(ng-click='questInit(); $close()', ng-if='party.members')=env.t('inviteParty') button.btn.btn-default(ng-click='closeQuest(); $close()')=env.t('questLater') .modal-footer(style='margin-top:0', ng-init='loadWidgets()')