From 0def903a895d57f41aa50c5f538b34912dc04d00 Mon Sep 17 00:00:00 2001 From: Laila Los <44241786+ElectronicBlueberry@users.noreply.github.com> Date: Fri, 15 Mar 2024 13:34:44 +0100 Subject: [PATCH 1/3] fix id unknown --- client/src/stores/userTagsStore.ts | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/client/src/stores/userTagsStore.ts b/client/src/stores/userTagsStore.ts index ce5b449a1554..36a20a92b15b 100644 --- a/client/src/stores/userTagsStore.ts +++ b/client/src/stores/userTagsStore.ts @@ -20,7 +20,7 @@ class UserTagStoreDatabase extends Dexie { constructor() { super("userTagStoreDatabase"); - this.version(1).stores({ tags: "++id, userHash, lastUsed" }); + this.version(2).stores({ tags: "++id, userHash, lastUsed, tag" }); } } @@ -113,12 +113,17 @@ export const useUserTagsStore = defineStore("userTagsStore", () => { await until(dbLoaded).toBe(true); tag = normalizeTag(tag); - const storedTag = tags.value.find((o) => o.tag === tag); - const id = storedTag?.id; + const dbTag = await db.tags.get({ tag }); - if (id !== undefined) { - // put instead of update, because `removeOldestEntries` may have deleted this tag on init - await db.tags.put({ ...storedTag, lastUsed: Date.now() } as StoredTag, id); + if (dbTag) { + await db.tags.update(dbTag, { lastUsed: Date.now() }); + } else { + const storedTag = tags.value.find((o) => o.tag === tag); + const id = storedTag?.id; + + if (id !== undefined) { + await db.tags.add({ ...storedTag, lastUsed: Date.now() } as StoredTag); + } } } From 61efe13f4711027a5449102c17dba561ea9adbd3 Mon Sep 17 00:00:00 2001 From: Laila Los <44241786+ElectronicBlueberry@users.noreply.github.com> Date: Fri, 15 Mar 2024 13:45:02 +0100 Subject: [PATCH 2/3] fix sorting and toggling for named tags --- .../src/components/TagsMultiselect/HeadlessMultiselect.vue | 7 +++++-- client/src/components/TagsMultiselect/StatelessTags.vue | 2 +- client/src/stores/userTagsStore.ts | 2 +- 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/client/src/components/TagsMultiselect/HeadlessMultiselect.vue b/client/src/components/TagsMultiselect/HeadlessMultiselect.vue index 3a07de33a790..95660d1ced83 100644 --- a/client/src/components/TagsMultiselect/HeadlessMultiselect.vue +++ b/client/src/components/TagsMultiselect/HeadlessMultiselect.vue @@ -15,6 +15,7 @@ import { computed, nextTick, ref, watch } from "vue"; import Vue2Teleport from "vue2-teleport"; import { useUid } from "@/composables/utils/uid"; +import { normalizeTag } from "@/stores/userTagsStore"; library.add(faCheck, faChevronUp, faPlus, faTags, faTimes); @@ -147,6 +148,8 @@ function getOptionWithId(id: number) { * was not part of the provided options */ function onOptionSelected(option: string) { + option = normalizeTag(option); + if (!optionsAsSet.value.has(option)) { emit("addOption", option); return; @@ -318,7 +321,7 @@ whenever(isOpen, async () => { :data-parent-id="props.id" class="headless-multiselect__option" role="option" - :aria-selected="props.selected.includes(option)" + :aria-selected="props.selected.includes(normalizeTag(option))" :class="{ invalid: i === 0 && !searchValueValid, highlighted: highlightedOption === i, @@ -332,7 +335,7 @@ whenever(isOpen, async () => { {{ option }} - +