From 5ac758cc72189903688f473c723135fcaa1be93b Mon Sep 17 00:00:00 2001 From: Matchu Date: Tue, 20 Apr 2021 01:50:42 -0700 Subject: [PATCH] Oops, don't allow saving existing outfits Ah, oops, the `id` field from `useOutfitState` went missing and I didn't notice, so `useOutfitSaving` didn't correctly detect that this was an existing outfit! This made saves on existing outfits create new copies, which isn't a bad behavior exactly, but I don't want to go there; saving a copy is just gonna pollute people's outfit lists rn, worse than no option imo. --- src/app/WardrobePage/ItemsPanel.js | 4 +++- src/app/WardrobePage/useOutfitState.js | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/app/WardrobePage/ItemsPanel.js b/src/app/WardrobePage/ItemsPanel.js index ecba292..16d504a 100644 --- a/src/app/WardrobePage/ItemsPanel.js +++ b/src/app/WardrobePage/ItemsPanel.js @@ -255,13 +255,15 @@ function useOutfitSaving(outfitState) { const history = useHistory(); const toast = useToast(); - const isSaved = outfitState.id; + const isSaved = Boolean(outfitState.id); // Only logged-in users can save outfits - and they can only save new outfits, // or outfits they created. const canSaveOutfit = isLoggedIn && (!isSaved || outfitState.creator?.id === currentUserId) && + // TODO: Add support for updating outfits + !isSaved && // TODO: Add support for outfits with items outfitState.wornItemIds.length === 0 && outfitState.closetedItemIds.length === 0; diff --git a/src/app/WardrobePage/useOutfitState.js b/src/app/WardrobePage/useOutfitState.js index 7fd2d1d..7ab1a65 100644 --- a/src/app/WardrobePage/useOutfitState.js +++ b/src/app/WardrobePage/useOutfitState.js @@ -107,7 +107,7 @@ function useOutfitState() { // IDs. It's more convenient to manage them as a Set in state, but most // callers will find it more convenient to access them as arrays! e.g. for // `.map()`. - const { name, speciesId, colorId, pose, appearanceId } = outfitState; + const { id, name, speciesId, colorId, pose, appearanceId } = outfitState; const wornItemIds = Array.from(outfitState.wornItemIds); const closetedItemIds = Array.from(outfitState.closetedItemIds); const allItemIds = [...wornItemIds, ...closetedItemIds]; @@ -218,7 +218,7 @@ function useOutfitState() { const url = buildOutfitUrl(outfitState); const outfitStateWithExtras = { - id: urlOutfitState.outfitId, + id, creator, zonesAndItems, incompatibleItems,