From 105f54ac720c00996881202ca96fdd400254fc34 Mon Sep 17 00:00:00 2001 From: Wolfsblvt Date: Sun, 28 Jul 2024 23:41:28 +0200 Subject: [PATCH] Check on existing tag names too --- public/scripts/tags.js | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/public/scripts/tags.js b/public/scripts/tags.js index cc1010291..6df7d119a 100644 --- a/public/scripts/tags.js +++ b/public/scripts/tags.js @@ -1464,12 +1464,19 @@ async function onTagRestoreFileSelect(e) { continue; } - const existingTag = tags.find(x => x.id === tag.id); + // Check against both existing id (direct match) and tag with the same name, which is not allowed. + let existingTag = tags.find(x => x.id === tag.id); + if (existingTag && !overwrite) { + warnings.push(`Tag '${tag.name}' with id ${tag.id} already exists.`); + continue; + } + existingTag = getTag(tag.name); + if (existingTag && !overwrite) { + warnings.push(`Tag with name '${tag.name}' already exists.`); + continue; + } + if (existingTag) { - if (!overwrite) { - warnings.push(`Tag with id ${tag.id} already exists.`); - continue; - } // On overwrite, we remove and re-add the tag removeFromArray(tags, existingTag); } @@ -1491,7 +1498,7 @@ async function onTagRestoreFileSelect(e) { const groupExists = groups.some(x => String(x.id) === String(key)); if (!characterExists && !groupExists) { - warnings.push(`Tag map key ${key} does not exist.`); + warnings.push(`Tag map key ${key} does not exist as character or group.`); continue; }