From f9a47b1420dbaf47811e09bcf8df8500dacff744 Mon Sep 17 00:00:00 2001 From: Travis Date: Fri, 9 Mar 2018 13:11:42 -0800 Subject: [PATCH] Update user pinned items on purchases. (#10085) fixes #10049 --- test/common/ops/buy/buyGear.js | 11 +++++++++++ website/client/store/actions/shops.js | 6 +----- website/common/script/ops/buy/buyGear.js | 2 +- 3 files changed, 13 insertions(+), 6 deletions(-) diff --git a/test/common/ops/buy/buyGear.js b/test/common/ops/buy/buyGear.js index 390cb29c67..bd1798a673 100644 --- a/test/common/ops/buy/buyGear.js +++ b/test/common/ops/buy/buyGear.js @@ -78,6 +78,17 @@ describe('shared.ops.buyGear', () => { expect(user.items.gear.equipped).to.have.property('armor', 'armor_warrior_1'); }); + it('updates the pinnedItems to the next item in the set if one exists', () => { + user.stats.gp = 31; + + buyGear(user, {params: {key: 'armor_warrior_1'}}); + + expect(user.pinnedItems).to.deep.include({ + type: 'marketGear', + path: 'gear.flat.armor_warrior_2', + }); + }); + it('buyGears equipment but does not auto-equip', () => { user.stats.gp = 31; user.preferences.autoEquip = false; diff --git a/website/client/store/actions/shops.js b/website/client/store/actions/shops.js index ca109b735d..56bbf4ac9b 100644 --- a/website/client/store/actions/shops.js +++ b/website/client/store/actions/shops.js @@ -19,13 +19,9 @@ function buyItem (store, params) { const quantity = params.quantity || 1; const user = store.state.user.data; - const userPinned = user.pinnedItems.slice(); let opResult = buyOp(user, {params, quantity}); - // @TODO: Currently resetting the pinned items will reset the market. Purchasing some items does not reset pinned. - // For now, I've added this hack for items like contributor gear to update while I am working on add more computed - // properties to the market. We will use this quick fix while testing the other changes. - user.pinnedItems = userPinned; + user.pinnedItems = opResult[0].pinnedItems; return { diff --git a/website/common/script/ops/buy/buyGear.js b/website/common/script/ops/buy/buyGear.js index 7250f74e3f..e811dd6fb4 100644 --- a/website/common/script/ops/buy/buyGear.js +++ b/website/common/script/ops/buy/buyGear.js @@ -76,7 +76,7 @@ module.exports = function buyGear (user, req = {}, analytics) { } return [ - pick(user, splitWhitespace('items achievements stats flags')), + pick(user, splitWhitespace('items achievements stats flags pinnedItems')), message, ]; };