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:
@@ -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, {
|
||||
|
||||
Reference in New Issue
Block a user