fix: ask before replacing a saved preset

Saving a character, object, or scene reused an existing name and
overwrote that preset without asking. Updating the preset already
linked to the region still saves directly.
This commit is contained in:
by-ae
2026-11-01 07:31:19 +10:00
parent 17858e1963
commit 479e0bb069
4 changed files with 61 additions and 5 deletions
+13
View File
@@ -13,6 +13,19 @@ export function normalizeStoreName(name) {
return String(name ?? "").trim().normalize("NFC");
}
/**
* Stored name this save would replace, or null.
* Saving the preset already linked to the region is an update, not a replacement.
*/
export function savedPresetCollision(existingNames, name, linkedName) {
const target = normalizeStoreName(name);
if (!target) return null;
const match = (existingNames || []).find((entry) => normalizeStoreName(entry) === target);
if (!match) return null;
if (linkedName && normalizeStoreName(linkedName) === target) return null;
return match;
}
export async function loadStores() {
try {
const resp = await fetch(STORE_API, {