diff --git a/src/app/WardrobePage/useOutfitSaving.js b/src/app/WardrobePage/useOutfitSaving.js index e0c754e..e182857 100644 --- a/src/app/WardrobePage/useOutfitSaving.js +++ b/src/app/WardrobePage/useOutfitSaving.js @@ -113,15 +113,15 @@ function useOutfitSaving(outfitState, dispatchToOutfit) { }, }); - // Also, send a `reset` action, to show whatever the server returned. - // This is important for suffix changes to `name`, but can also be - // relevant for graceful failure when a bug causes a change not to - // persist. (But don't do it if it's not the current outfit anymore, - // we don't want laggy mutations to reset the outfit!) + // Also, send a `rename` action, if this is still the current outfit, + // and the server renamed it (e.g. "Untitled outfit (1)"). (It's + // tempting to do a full reset, in case the server knows something we + // don't, but we don't want to clobber changes the user made since + // starting the save!) if (outfit.id === outfitState.id) { dispatchToOutfit({ - type: "resetToSavedOutfitData", - savedOutfitData: outfit, + type: "rename", + outfitName: outfit.name, }); } }, diff --git a/src/server/types/Outfit.js b/src/server/types/Outfit.js index c3c4bc1..42287c9 100644 --- a/src/server/types/Outfit.js +++ b/src/server/types/Outfit.js @@ -165,7 +165,7 @@ const resolvers = { // Then, get the unique name to use for this outfit: try the provided // name first, but, if it's taken, add a "(1)" suffix and keep // incrementing it until it's not. - let name = rawName; + let name = rawName || "Untitled outfit"; for (let i = 1; existingOutfitNames.has(name); i++) { name = `${baseName} (${i})`; }