fix isPinned : check if pinnedItems-array exists

This commit is contained in:
negue
2017-08-24 18:49:14 +02:00
committed by GitHub
parent a86166742f
commit 748ce8a23f

View File

@@ -2,8 +2,8 @@ module.exports = function isPinned (user, item) {
if (user === null)
return false;
const isUnpinned = user.unpinnedItems.findIndex(unpinned => unpinned.path === item.path) > -1;
const pinnedItem = user.pinnedItems.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;
return pinnedItem && !isUnpinned;
return isItemPinned && !isItemUnpinned;
};