Skip to content

Commit

Permalink
allow for both kinds of review in the same file
Browse files Browse the repository at this point in the history
  • Loading branch information
st3v3nmw committed Apr 19, 2021
1 parent d6686c7 commit 06cda88
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions src/main.ts
Expand Up @@ -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();
});

Expand Down Expand Up @@ -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();
Expand All @@ -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)
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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 || <Record<string, any>>{};
Expand Down

0 comments on commit 06cda88

Please sign in to comment.