fix: resolve error when similar texts exist

This commit is contained in:
2026-02-04 09:57:03 +05:00
parent f9f1693e44
commit e29630314c
2 changed files with 11 additions and 2 deletions
+8
View File
@@ -63,11 +63,19 @@
}
function handleAddText(text: string) {
// Проверяем, что текст не пустой и не дублируется
if (!text.trim()) return;
if (texts.some(t => t.text === text)) return;
texts = [...texts, { id: crypto.randomUUID(), text }];
updatePanelsFromTexts();
}
function handleUpdateText(id: string, newText: string) {
// Проверяем, что текст не пустой и не дублируется
if (!newText.trim()) return;
if (texts.some(t => t.id !== id && t.text === newText)) return;
texts = texts.map(t => t.id === id ? { ...t, text: newText } : t);
updatePanelsFromTexts();
}