diff --git a/webapp/src/components/AutomationList/TagDB.ts b/webapp/src/components/AutomationList/TagDB.ts index 8bb361a..759baf4 100644 --- a/webapp/src/components/AutomationList/TagDB.ts +++ b/webapp/src/components/AutomationList/TagDB.ts @@ -2,11 +2,14 @@ import { AutomationData } from "types/automations"; export type TagDB = ReturnType; export const makeTagDB = (automations: AutomationData[]) => { - const allTags: Record = {}; + const allTags: Record> = {}; automations.forEach(({ tags }) => Object.keys(tags).forEach(tagName => { const tagValue = tags[tagName]; - allTags[tagName] = (allTags[tagName] ?? []).concat([tagValue]); + if (!allTags[tagName]) { + allTags[tagName] = new Set() + } + allTags[tagName].add(tagValue); }) ); const allTagNames = Object.keys(allTags); @@ -15,7 +18,7 @@ export const makeTagDB = (automations: AutomationData[]) => { return allTagNames.filter(n => !myTags.includes(n)) }, getTagValues(tagName: string): string[] { - return allTags[tagName] ?? []; + return allTags[tagName] ? Array.from(allTags[tagName].values()) : []; } } } \ No newline at end of file