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.
This commit is contained in:
Emi Matchu 2021-04-20 01:50:42 -07:00
parent 3f66dd7244
commit 5ac758cc72
2 changed files with 5 additions and 3 deletions

View file

@ -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;

View file

@ -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,