mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
Fixed quest drop modal (#7377)
* Fixed quest drop modal * Fixed broken party test
This commit is contained in:
committed by
Matteo Pagliazzi
parent
d36c514c06
commit
f4ca97ffc3
@@ -51,7 +51,9 @@ describe("Party Controller", function() {
|
|||||||
var syncParty = sinon.stub(groups.Group, 'syncParty')
|
var syncParty = sinon.stub(groups.Group, 'syncParty')
|
||||||
syncParty.returns(Promise.resolve(groupResponse));
|
syncParty.returns(Promise.resolve(groupResponse));
|
||||||
$controller('PartyCtrl', { $scope: scope, $state: state, User: User });
|
$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
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ habitrpg.controller('NotificationCtrl',
|
|||||||
}
|
}
|
||||||
|
|
||||||
$rootScope.$watch('user.stats.lvl', function(after, before) {
|
$rootScope.$watch('user.stats.lvl', function(after, before) {
|
||||||
if (after <= before) return;
|
if (after <= before) return;
|
||||||
Notification.lvl();
|
Notification.lvl();
|
||||||
$rootScope.playSound('Level_Up');
|
$rootScope.playSound('Level_Up');
|
||||||
if (User.user._tmp && User.user._tmp.drop && (User.user._tmp.drop.type === 'Quest')) return;
|
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);
|
Notification.drop(env.t('messageDropFood', {dropArticle: after.article, dropText: text, dropNotes: notes}), after);
|
||||||
} else if (after.type === 'Quest') {
|
} else if (after.type === 'Quest') {
|
||||||
$rootScope.selectedQuest = Content.quests[after.key];
|
$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') {
|
} else if (after.notificationType === 'Mystery') {
|
||||||
text = Content.gear.flat[after.key].text();
|
text = Content.gear.flat[after.key].text();
|
||||||
Notification.drop(env.t('messageDropMysteryItem', {dropText: text}), after);
|
Notification.drop(env.t('messageDropMysteryItem', {dropText: text}), after);
|
||||||
|
|||||||
@@ -11,15 +11,13 @@ habitrpg.controller("PartyCtrl", ['$rootScope','$scope','Groups','Chat','User','
|
|||||||
$scope.inviteOrStartParty = Groups.inviteOrStartParty;
|
$scope.inviteOrStartParty = Groups.inviteOrStartParty;
|
||||||
$scope.loadWidgets = Social.loadWidgets;
|
$scope.loadWidgets = Social.loadWidgets;
|
||||||
|
|
||||||
if ($state.is('options.social.party')) {
|
Groups.Group.syncParty()
|
||||||
Groups.Group.syncParty()
|
.then(function successCallback(group) {
|
||||||
.then(function successCallback(group) {
|
$rootScope.party = $scope.group = group;
|
||||||
$rootScope.party = $scope.group = group;
|
checkForNotifications();
|
||||||
checkForNotifications();
|
}, function errorCallback(response) {
|
||||||
}, function errorCallback(response) {
|
$rootScope.party = $scope.group = $scope.newGroup = { type: 'party' };
|
||||||
$rootScope.party = $scope.group = $scope.newGroup = { type: 'party' };
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
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.
|
||||||
@@ -148,6 +146,15 @@ habitrpg.controller("PartyCtrl", ['$rootScope','$scope','Groups','Chat','User','
|
|||||||
User.set({'invitations.party':{}});
|
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(){
|
$scope.questCancel = function(){
|
||||||
if (!confirm(window.env.t('sureCancel'))) return;
|
if (!confirm(window.env.t('sureCancel'))) return;
|
||||||
|
|
||||||
|
|||||||
@@ -104,7 +104,8 @@ script(type='text/ng-template', id='modals/questDrop.html')
|
|||||||
.quest-icon(class='inventory_quest_scroll_{{::selectedQuest.key}}')
|
.quest-icon(class='inventory_quest_scroll_{{::selectedQuest.key}}')
|
||||||
h4!=env.t('leveledUpReceivedQuest', {level:'{{user.stats.lvl}}'})
|
h4!=env.t('leveledUpReceivedQuest', {level:'{{user.stats.lvl}}'})
|
||||||
.row(style='margin-top:2em')
|
.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-primary(ng-click='questInit(); $close()', ng-if='party.members')=env.t('inviteParty')
|
||||||
button.btn.btn-default(ng-click='closeQuest(); $close()')=env.t('questLater')
|
button.btn.btn-default(ng-click='closeQuest(); $close()')=env.t('questLater')
|
||||||
.modal-footer(style='margin-top:0', ng-init='loadWidgets()')
|
.modal-footer(style='margin-top:0', ng-init='loadWidgets()')
|
||||||
|
|||||||
Reference in New Issue
Block a user