diff --git a/src/lib/db/entities/tags.ts b/src/lib/db/entities/tags.ts index a0d94e5..8108b64 100644 --- a/src/lib/db/entities/tags.ts +++ b/src/lib/db/entities/tags.ts @@ -30,12 +30,15 @@ export async function newTag(tag: Omit) { export async function removeTag(uuid: UUID){ const tag = await getTable().get(uuid); + console.log(tag); if(tag?.type === "member"){ - getMembers().toCollection().modify(member => { + await getMembers().toCollection().modify(member => { + console.log(member.tags); member.tags = member.tags?.filter(tag => tag !== uuid) + console.log(member.tags); }); } else if(tag?.type === "journal") { - getJournalPosts().toCollection().modify(journalPost => { + await getJournalPosts().toCollection().modify(journalPost => { journalPost.tags = journalPost.tags?.filter(tag => tag !== uuid) }); } diff --git a/src/views/tabbed/Members.vue b/src/views/tabbed/Members.vue index c691685..b4fc687 100644 --- a/src/views/tabbed/Members.vue +++ b/src/views/tabbed/Members.vue @@ -11,23 +11,26 @@ IonFabButton, IonIcon } from '@ionic/vue'; - import { inject, onMounted, provide, ref } from 'vue'; + import { inject, onMounted, provide, ref, watch } from 'vue'; import { getFilteredMembers } from '../../lib/db/liveQueries'; import { addOutline as addIOS } from "ionicons/icons"; import addMD from "@material-design-icons/svg/outlined/add.svg"; import MemberEdit from '../../modals/MemberEdit.vue'; import MemberInList from '../../components/MemberInList.vue'; import { Tag, getTable as getTagsTable } from '../../lib/db/entities/tags'; +import { from, useObservable } from '@vueuse/rxjs'; +import { liveQuery } from 'dexie'; const isIOS = inject("isIOS"); const tags = ref([]); provide("tags", tags); - onMounted(loadTags); - async function loadTags(){ + watch([ + useObservable(from(liveQuery(() => getTagsTable().toArray()))) + ], async () => { tags.value = await getTagsTable().toArray(); - } + }, { immediate: true }); const search = ref(""); const members = getFilteredMembers(search);