mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-03 04:29:40 +00:00
refactor(client): extract find pet logic into function
This commit is contained in:
parent
4ad50b9d30
commit
9c0998c29a
1 changed files with 8 additions and 4 deletions
|
|
@ -378,18 +378,22 @@ habitrpg.controller("InventoryCtrl",
|
|||
};
|
||||
|
||||
$scope.shouldShowPremiumMountSection = function () {
|
||||
var pets = Object.keys(user.items.pets);
|
||||
return pets.find(function (petKey) {
|
||||
var pet = Content.petInfo[petKey];
|
||||
return findPet(function (pet) {
|
||||
return pet.type === 'premium';
|
||||
});
|
||||
};
|
||||
|
||||
$scope.hasAPetOfPotion = function (potion) {
|
||||
return findPet(function (pet) {
|
||||
return pet.potion === potion;
|
||||
});
|
||||
};
|
||||
|
||||
function findPet (fn) {
|
||||
var pets = Object.keys(user.items.pets);
|
||||
return pets.find(function (petKey) {
|
||||
var pet = Content.petInfo[petKey];
|
||||
return pet.potion === potion;
|
||||
return fn(pet);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue