Skip to content

Commit

Permalink
Added check to tags fixing #142
Browse files Browse the repository at this point in the history
  • Loading branch information
flankstaek committed Jul 22, 2022
1 parent 601f623 commit 6b20c1f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export const getTagMeta = (tag: string): TagMeta => {
return { main, sub }
}

export const retrieveTag = (tagMeta: TagMeta): string => {
return tagMeta.main ? tagMeta.main : tagMeta.sub ? tagMeta.sub : ''
}

export const mapLinkMeta = (linkMeta: LinkMeta[]) => {
const map = new Map<string, LinkMeta>()
for (const link of linkMeta) map.set(link.filePath, link)
Expand Down
5 changes: 3 additions & 2 deletions src/utils/tasks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
getFrontmatterTags,
getIndentationSpacesFromTodoLine,
getTagMeta,
retrieveTag,
lineIsValidTodo,
mapLinkMeta,
removeTagFromText,
Expand Down Expand Up @@ -58,12 +59,12 @@ export const parseTodos = async (
if (todoTags.length === 1 && todoTags[0] === "*") return true
const fileCache = cache.getFileCache(file)
const allTags = getAllTagsFromMetadata(fileCache)
const tagsOnPage = allTags.filter((tag) => todoTags.includes(getTagMeta(tag).main.toLowerCase()))
const tagsOnPage = allTags.filter((tag) => todoTags.includes(retrieveTag(getTagMeta(tag)).toLowerCase()))
return tagsOnPage.length > 0
})
.map<Promise<FileInfo>>(async (file) => {
const fileCache = cache.getFileCache(file)
const tagsOnPage = fileCache?.tags?.filter((e) => todoTags.includes(getTagMeta(e.tag).main.toLowerCase())) ?? []
const tagsOnPage = fileCache?.tags?.filter((e) => todoTags.includes(retrieveTag(getTagMeta(e.tag)).toLowerCase())) ?? []
const frontMatterTags = getFrontmatterTags(fileCache, todoTags)
const hasFrontMatterTag = frontMatterTags.length > 0
const parseEntireFile = todoTags[0] === "*" || hasFrontMatterTag || showAllTodos
Expand Down

0 comments on commit 6b20c1f

Please sign in to comment.