start fixing commong

This commit is contained in:
Matteo Pagliazzi
2019-10-09 16:51:17 +02:00
parent 9cd43db401
commit 0c27fb24a5
76 changed files with 442 additions and 275 deletions

View File

@@ -1,9 +1,12 @@
export default function isPinned (user, item, checkOfficialPinnedItems /* getOfficialPinnedItems */) {
export default function isPinned (user, item, checkOfficialPinnedItems) {
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;
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;