Update user pinned items on purchases. (#10085)

fixes #10049
This commit is contained in:
Travis
2018-03-09 13:11:42 -08:00
committed by Sabe Jones
parent 07b3824c4c
commit f9a47b1420
3 changed files with 13 additions and 6 deletions
+11
View File
@@ -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;
+1 -5
View File
@@ -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 {
+1 -1
View File
@@ -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,
];
};