mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 15:17:25 +01:00
fortify potion + fix pinning check (#9089)
This commit is contained in:
@@ -116,28 +116,31 @@ function removePinnedItemsByOwnedGear (user) {
|
||||
});
|
||||
}
|
||||
|
||||
const PATHS_WITHOUT_ITEM = ['special.gems', 'special.rebirth_orb', 'special.fortify'];
|
||||
|
||||
/**
|
||||
* @returns {boolean} TRUE added the item / FALSE removed it
|
||||
*/
|
||||
function togglePinnedItem (user, {item, type, path}, req = {}) {
|
||||
let arrayToChange;
|
||||
let officialPinnedItems = getOfficialPinnedItems(user);
|
||||
|
||||
if (!path) {
|
||||
// If path isn't passed it means an item was passed
|
||||
path = getItemInfo(user, type, item, req.language).path;
|
||||
path = getItemInfo(user, type, item, officialPinnedItems, req.language).path;
|
||||
} else {
|
||||
if (!item) {
|
||||
item = get(content, path);
|
||||
}
|
||||
|
||||
if (!item) {
|
||||
if (!item && PATHS_WITHOUT_ITEM.indexOf(path) === -1) {
|
||||
// path not exists in our content structure
|
||||
|
||||
throw new BadRequest(i18n.t('wrongItemPath', {path}, req.language));
|
||||
}
|
||||
|
||||
// check if item exists & valid to be pinned
|
||||
getItemInfo(user, type, item, req.language);
|
||||
getItemInfo(user, type, item, officialPinnedItems, req.language);
|
||||
}
|
||||
|
||||
|
||||
@@ -145,8 +148,6 @@ function togglePinnedItem (user, {item, type, path}, req = {}) {
|
||||
throw new BadRequest(i18n.t('cannotUnpinArmoirPotion', req.language));
|
||||
}
|
||||
|
||||
let officialPinnedItems = getOfficialPinnedItems(user);
|
||||
|
||||
let isOfficialPinned = officialPinnedItems.find(officialPinnedItem => {
|
||||
return officialPinnedItem.path === path;
|
||||
}) !== undefined;
|
||||
|
||||
Reference in New Issue
Block a user