diff --git a/src/main.ts b/src/main.ts index 51a495e8..cc78324c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -77,7 +77,7 @@ export default class SRPlugin extends Plugin { }); this.addRibbonIcon("crosshairs", "Review flashcards", async () => { - await this.sync(true); + await this.flashcards_sync(); new FlashcardModal(this.app, this).open(); }); @@ -174,7 +174,7 @@ export default class SRPlugin extends Plugin { }); } - async sync(find_flashcards: boolean = false) { + async sync() { let notes = this.app.vault.getMarkdownFiles(); graph.reset(); @@ -185,9 +185,6 @@ export default class SRPlugin extends Plugin { this.pageranks = {}; this.dueNotesCount = 0; - this.newFlashcards = []; - this.dueFlashcards = []; - let now = Date.now(); for (let note of notes) { if (this.incomingLinks[note.path] == undefined) @@ -217,11 +214,6 @@ export default class SRPlugin extends Plugin { let tags = fileCachedData.tags || []; let shouldIgnore = true; for (let tagObj of tags) { - if (tagObj.tag == this.data.settings.flashcardsTag) { - if (find_flashcards) await this.findFlashcards(note); - break; - } - if (this.data.settings.tagsToReview.includes(tagObj.tag)) { shouldIgnore = false; break; @@ -279,6 +271,25 @@ export default class SRPlugin extends Plugin { this.reviewQueueView.redraw(); } + async flashcards_sync() { + let notes = this.app.vault.getMarkdownFiles(); + + this.newFlashcards = []; + this.dueFlashcards = []; + + for (let note of notes) { + let fileCachedData = + this.app.metadataCache.getFileCache(note) || {}; + let tags = fileCachedData.tags || []; + for (let tagObj of tags) { + if (tagObj.tag == this.data.settings.flashcardsTag) { + await this.findFlashcards(note); + break; + } + } + } + } + async saveReviewResponse(note: TFile, response: ReviewResponse) { let fileCachedData = this.app.metadataCache.getFileCache(note) || {}; let frontmatter = fileCachedData.frontmatter || >{};