From e1eb33ad260e5da0ec6859baa2368d8a08538e11 Mon Sep 17 00:00:00 2001 From: Scott Worley Date: Thu, 27 Jan 2022 11:59:03 -0800 Subject: [PATCH] Don't attempt to create duplicate tags --- vopamoi.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/vopamoi.ts b/vopamoi.ts index 5ac82ef..7c51935 100644 --- a/vopamoi.ts +++ b/vopamoi.ts @@ -77,6 +77,15 @@ const Model = { return target; }, + hasTag: function (task: Element, tag: string) { + for (const child of task.children) { + if (child.classList.contains("tag") && child.textContent === tag) { + return true; + } + } + return false; + }, + getPriority: function (task: Element): number { if (task.hasAttribute("data-priority")) { return parseFloat(task.getAttribute("data-priority")!); @@ -270,7 +279,9 @@ function BrowserUI() { input.removeEventListener("blur", this.completeTagEdit); task.removeChild(input); task.focus(); - ui.addTag(task.getAttribute("data-created")!, newTagName); + if (!Model.hasTag(task, newTagName)) { + ui.addTag(task.getAttribute("data-created")!, newTagName); + } }, firstVisibleTask: function () { -- 2.44.1