From f3173db7b3bc16ff8b91b18b96df582c654a4444 Mon Sep 17 00:00:00 2001 From: Matchu Date: Mon, 26 Apr 2021 07:21:47 -0700 Subject: [PATCH] Fix bug unwearing/removing search results MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Oops, our "items to reconsider" feature was preventing unwearing/removing items you're already wearing! This feature helps you try stuff in Search, without disrupting your outfit. e.g. if you try on a new Background, then change your mind and unwear it, then we reapply whatever old Background you had on the outfit before. But this made it impossible to remove your _current_ background from the search page if you went back and searched for it again, because we would remove it and then reconsider and reapply it 😅 Now we, um, stop that! --- src/app/WardrobePage/useOutfitState.js | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/app/WardrobePage/useOutfitState.js b/src/app/WardrobePage/useOutfitState.js index 07885c5..1409643 100644 --- a/src/app/WardrobePage/useOutfitState.js +++ b/src/app/WardrobePage/useOutfitState.js @@ -248,6 +248,7 @@ function useOutfitState() { } const outfitStateReducer = (apolloClient) => (baseState, action) => { + console.log("[Outfit state] Action:", action); switch (action.type) { case "rename": return produce(baseState, (state) => { @@ -304,7 +305,12 @@ const outfitStateReducer = (apolloClient) => (baseState, action) => { wornItemIds.delete(itemId); closetedItemIds.add(itemId); - reconsiderItems(itemIdsToReconsider, state, apolloClient); + reconsiderItems( + // Don't include the unworn item in items to reconsider! + itemIdsToReconsider.filter((x) => x !== itemId), + state, + apolloClient + ); }); case "removeItem": return produce(baseState, (state) => { @@ -315,7 +321,12 @@ const outfitStateReducer = (apolloClient) => (baseState, action) => { wornItemIds.delete(itemId); closetedItemIds.delete(itemId); - reconsiderItems(itemIdsToReconsider, state, apolloClient); + reconsiderItems( + // Don't include the removed item in items to reconsider! + itemIdsToReconsider.filter((x) => x !== itemId), + state, + apolloClient + ); }); case "setPose": return produce(baseState, (state) => {