Files
habitica/website/common/script/libs/isPinned.js
Matteo Pagliazzi cca5b8492b fix exports
2019-10-01 17:53:48 +02:00

14 lines
641 B
JavaScript

export default function isPinned (user, item, checkOfficialPinnedItems /* getOfficialPinnedItems */) {
if (user === null)
return false;
const isPinnedOfficial = checkOfficialPinnedItems !== undefined && checkOfficialPinnedItems.findIndex(pinned => pinned.path === item.path) > -1;
const isItemUnpinned = user.unpinnedItems !== undefined && user.unpinnedItems.findIndex(unpinned => unpinned.path === item.path) > -1;
const isItemPinned = user.pinnedItems !== undefined && user.pinnedItems.findIndex(pinned => pinned.path === item.path) > -1;
if (isPinnedOfficial && !isItemUnpinned)
return true;
return isItemPinned;
}