mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
Preventing users from buying already gifted subscriber items (#7734)
* Adding the unopened mystery items to the call to get not obtained subscriber items. closes #7712 * refactoring according to pr * Refactoring according to pr. moved time-travelers to it's own file and added new tests.
This commit is contained in:
@@ -371,9 +371,16 @@ habitrpg.controller("InventoryCtrl",
|
||||
$scope.hasAllTimeTravelerItemsOfType('mounts'));
|
||||
};
|
||||
|
||||
$scope.shouldShowTimeTravelerItem = function(category, item) {
|
||||
if (category.identifier === 'pets' || category.identifier === 'mounts') {
|
||||
return !user.items[category.identifier][item.key];
|
||||
}
|
||||
return !user.items.gear.owned[item.key] && user.purchased.plan.mysteryItems.indexOf(item.key) === -1;
|
||||
};
|
||||
|
||||
$scope.hasAllTimeTravelerItemsOfType = function(type) {
|
||||
if (type === 'mystery') {
|
||||
var itemsLeftInTimeTravelerStore = Content.timeTravelerStore(user.items.gear.owned);
|
||||
var itemsLeftInTimeTravelerStore = Content.timeTravelerStore(user);
|
||||
var keys = Object.keys(itemsLeftInTimeTravelerStore);
|
||||
|
||||
return keys.length === 0;
|
||||
|
||||
Reference in New Issue
Block a user