X-Git-Url: http://git.scottworley.com/vopamoi/blobdiff_plain/e1eb33ad260e5da0ec6859baa2368d8a08538e11..3916a89c8a391d43c8160409862bcba18259f659:/vopamoi.ts?ds=inline diff --git a/vopamoi.ts b/vopamoi.ts index 7c51935..3b2f163 100644 --- a/vopamoi.ts +++ b/vopamoi.ts @@ -44,6 +44,8 @@ const Model = { addTag: function (createTimestamp: string, tagName: string): Element | null { const task = this.getTask(createTimestamp); if (!task) return null; + const existingTag = this.hasTag(task, tagName); + if (existingTag) return existingTag; const tag = document.createElement("span"); tag.appendChild(document.createTextNode(tagName)); tag.classList.add("tag"); @@ -77,13 +79,13 @@ const Model = { return target; }, - hasTag: function (task: Element, tag: string) { + hasTag: function (task: Element, tag: string): Element | null { for (const child of task.children) { if (child.classList.contains("tag") && child.textContent === tag) { - return true; + return child; } } - return false; + return null; }, getPriority: function (task: Element): number {