diff --git a/Utils/RuleMatcherUtil.ts b/Utils/RuleMatcherUtil.ts index f96ecaa..b5cf075 100644 --- a/Utils/RuleMatcherUtil.ts +++ b/Utils/RuleMatcherUtil.ts @@ -1,6 +1,6 @@ import type { MovingRule } from "Models/MovingRule"; import { ProjectRule } from "Models/ProjectRule"; -import type { TagCache, TFile } from "obsidian"; +import type { TFile } from "obsidian"; class RuleMatcherUtil { private static instance: RuleMatcherUtil; @@ -64,7 +64,7 @@ class RuleMatcherUtil { * @param rules * @returns MovingRule | null */ - public getMatchingRuleByTag(tags: TagCache[], rules: MovingRule[]): MovingRule | null { + public getMatchingRuleByTag(tags: string[], rules: MovingRule[]): MovingRule | null { for (const rule of rules) { if (rule.regex == null || rule.regex === "") { console.error("Tag Rule does not have a regex: ", rule); @@ -81,7 +81,7 @@ class RuleMatcherUtil { const regex = this.getCompiledRegex(rule.regex); for (const tag of tags) { - if (regex.test(tag.tag)) { + if (regex.test(tag)) { return rule; } } @@ -104,11 +104,11 @@ class RuleMatcherUtil { return matches; } - public getGroupMatchesForTags(tags: TagCache[], rule: MovingRule): RegExpMatchArray | null { + public getGroupMatchesForTags(tags: string[], rule: MovingRule): RegExpMatchArray | null { const regex = this.getCompiledRegex(rule.regex); // console.log("Compiled regex: ", regex); for (const tag of tags) { - const matches = tag.tag.match(regex); + const matches = tag.match(regex); if (matches) { return matches; } diff --git a/main.ts b/main.ts index e3b9a73..82fb6fe 100644 --- a/main.ts +++ b/main.ts @@ -137,7 +137,9 @@ export default class AutoMoverPlugin extends obsidian.Plugin { * @returns true if the file was moved, false otherwise */ matchAndMoveByTag(file: obsidian.TFile): boolean { - const tags = this.app.metadataCache.getFileCache(file)?.tags; + const cache = this.app.metadataCache.getFileCache(file); + if (cache == null) return false; + const tags = obsidian.getAllTags(cache); if (tags == null || tags.length === 0) return false; const tagRule = ruleMatcherUtil.getMatchingRuleByTag(tags, this.settings.tagRules); diff --git a/manifest.json b/manifest.json index 2ad16ae..ed42339 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "id": "auto-mover", "name": "AutoMover", - "version": "1.0.7", + "version": "1.0.8", "minAppVersion": "0.15.0", "description": "Move files and notes with specified names into their designated folders according to rules you define.", "author": "Al0cam", diff --git a/package.json b/package.json index 2b5abd2..99cb5a4 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "AutoMover", - "version": "1.0.7", + "version": "1.0.8", "description": "AutoMover: Move files and notes with specified names into their designated folders according to rules you define.", "main": "main.js", "scripts": { diff --git a/versions.json b/versions.json index d0c1a12..ab70f02 100644 --- a/versions.json +++ b/versions.json @@ -1,3 +1,3 @@ { - "1.0.7": "0.15.0" + "1.0.8": "0.15.0" }