2017-08-14 17:15:32 +00:00
|
|
|
import content from '../content/index';
|
|
|
|
|
import get from 'lodash/get';
|
|
|
|
|
import getItemInfo from './getItemInfo';
|
2017-08-24 05:16:18 +00:00
|
|
|
import shops from './shops';
|
2017-09-21 00:28:11 +00:00
|
|
|
import getOfficialPinnedItems from './getOfficialPinnedItems';
|
2017-08-14 17:15:32 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
module.exports = function getPinnedItems (user) {
|
2017-09-21 00:28:11 +00:00
|
|
|
let officialPinnedItems = getOfficialPinnedItems(user);
|
|
|
|
|
|
2017-08-14 17:15:32 +00:00
|
|
|
const officialPinnedItemsNotUnpinned = officialPinnedItems.filter(officialPin => {
|
|
|
|
|
const isUnpinned = user.unpinnedItems.findIndex(unpinned => unpinned.path === officialPin.path) > -1;
|
|
|
|
|
return !isUnpinned;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
const pinnedItems = officialPinnedItemsNotUnpinned.concat(user.pinnedItems);
|
|
|
|
|
|
2017-08-24 05:16:18 +00:00
|
|
|
let items = pinnedItems.map(({type, path}) => {
|
2017-09-21 00:28:11 +00:00
|
|
|
return getItemInfo(user, type, get(content, path), officialPinnedItems);
|
2017-08-14 17:15:32 +00:00
|
|
|
});
|
2017-08-24 05:16:18 +00:00
|
|
|
|
|
|
|
|
shops.checkMarketGearLocked(user, items);
|
|
|
|
|
|
|
|
|
|
return items;
|
2017-08-14 17:15:32 +00:00
|
|
|
};
|