diff --git a/app/components/Filter/CategorySelect.vue b/app/components/Filter/CategorySelect.vue index 31ffb3b..01ac71d 100644 --- a/app/components/Filter/CategorySelect.vue +++ b/app/components/Filter/CategorySelect.vue @@ -13,6 +13,8 @@ const { isMobile } = useDevice(); const { shift } = useMagicKeys(); + const { tags } = useFilter(); + function onPress(category: UUID, alwaysAdd: boolean) { if (activeCategorys.value.includes(category)) { activeCategorys.value = activeCategorys.value.filter( @@ -37,7 +39,20 @@ (todos.value ?? []).forEach((todo) => { if (!todo.category) return; - map.set(todo.category.uuid, (map.get(todo.category.uuid) ?? 0) + 1); + + if (tags.value.length === 0) { + map.set(todo.category.uuid, (map.get(todo.category.uuid) ?? 0) + 1); + return; + } + + const todoTagUuids = (todo.tags ?? []).map((t) => t.uuid); + const hasAllTags = tags.value.every((activeTag) => + todoTagUuids.includes(activeTag), + ); + + if (hasAllTags) { + map.set(todo.category.uuid, (map.get(todo.category.uuid) ?? 0) + 1); + } }); return map;