mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 14:47:53 +01:00
Don't $watch drops (#7547)
* WIP(drops): get drops out of _tmp * fix(notifications): no watch for drops/mystery * fix(ops): only two response values * fix(test): update op expectation Also update API docs for modified route. * fix(lint): remove trailing space * fix(test): update integration check
This commit is contained in:
@@ -82,55 +82,6 @@ habitrpg.controller('NotificationCtrl',
|
||||
}
|
||||
});
|
||||
|
||||
$rootScope.$watch('user._tmp.drop', function(after, before){
|
||||
// won't work when getting the same item twice?
|
||||
if (_.isEqual(after, before) || !after) return;
|
||||
var text, notes, type;
|
||||
$rootScope.playSound('Item_Drop');
|
||||
|
||||
// Note: For Mystery Item gear, after.type will be 'head', 'armor', etc
|
||||
// so we use after.notificationType below.
|
||||
|
||||
if (after.type !== 'gear' && after.type !== 'Quest' && after.notificationType !== 'Mystery') {
|
||||
if (after.type === 'Food') {
|
||||
type = 'food';
|
||||
} else if (after.type === 'HatchingPotion') {
|
||||
type = 'hatchingPotions';
|
||||
} else {
|
||||
type = after.type.toLowerCase() + 's';
|
||||
}
|
||||
if(!User.user.items[type][after.key]){
|
||||
User.user.items[type][after.key] = 0;
|
||||
}
|
||||
User.user.items[type][after.key]++;
|
||||
}
|
||||
|
||||
if (after.type === 'HatchingPotion'){
|
||||
text = Content.hatchingPotions[after.key].text();
|
||||
notes = Content.hatchingPotions[after.key].notes();
|
||||
Notification.drop(env.t('messageDropPotion', {dropText: text, dropNotes: notes}), after);
|
||||
} else if (after.type === 'Egg'){
|
||||
text = Content.eggs[after.key].text();
|
||||
notes = Content.eggs[after.key].notes();
|
||||
Notification.drop(env.t('messageDropEgg', {dropText: text, dropNotes: notes}), after);
|
||||
} else if (after.type === 'Food'){
|
||||
text = Content.food[after.key].text();
|
||||
notes = Content.food[after.key].notes();
|
||||
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'});
|
||||
} else if (after.notificationType === 'Mystery') {
|
||||
text = Content.gear.flat[after.key].text();
|
||||
Notification.drop(env.t('messageDropMysteryItem', {dropText: text}), after);
|
||||
} else {
|
||||
// Keep support for another type of drops that might be added
|
||||
Notification.drop(User.user._tmp.drop.dialog);
|
||||
}
|
||||
|
||||
Analytics.track({'hitType':'event','eventCategory':'behavior','eventAction':'acquire item','itemName':after.key,'acquireMethod':'Drop'});
|
||||
});
|
||||
|
||||
$rootScope.$watch('user.achievements.streak', function(after, before){
|
||||
if(before == undefined || after <= before) return;
|
||||
Notification.streak(User.user.achievements.streak);
|
||||
|
||||
Reference in New Issue
Block a user