From 4c48460f54c104606dc73442fccd4d0dfc1dadfc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=27Matti=27=20H=C3=A4hnel?= Date: Sun, 24 Mar 2024 16:53:34 +0200 Subject: [PATCH 1/2] Add option to check new notes before due notes - ... when deciding on the next note for review --- src/lang/locale/en.ts | 1 + src/main.ts | 37 +++++++++++++++++++++++++------------ src/settings.ts | 9 +++++++++ 3 files changed, 35 insertions(+), 12 deletions(-) diff --git a/src/lang/locale/en.ts b/src/lang/locale/en.ts index 2112229c..95bff323 100644 --- a/src/lang/locale/en.ts +++ b/src/lang/locale/en.ts @@ -110,6 +110,7 @@ export default { OPEN_RANDOM_NOTE: "Open a random note for review", OPEN_RANDOM_NOTE_DESC: "When you turn this off, notes are ordered by importance (PageRank).", AUTO_NEXT_NOTE: "Open next note automatically after a review", + AUTO_NEXT_NEW_NOTE: "Pick new before due notes when picking the next note to review", DISABLE_FILE_MENU_REVIEW_OPTIONS: "Disable review options in the file menu i.e. Review: Easy Good Hard", DISABLE_FILE_MENU_REVIEW_OPTIONS_DESC: diff --git a/src/main.ts b/src/main.ts index a8c3c278..d807da51 100644 --- a/src/main.ts +++ b/src/main.ts @@ -756,20 +756,33 @@ export default class SRPlugin extends Plugin { this.lastSelectedReviewDeck = deckKey; const deck = this.reviewDecks[deckKey]; - if (deck.dueNotesCount > 0) { - const index = this.data.settings.openRandomNote - ? Math.floor(Math.random() * deck.dueNotesCount) - : 0; - await this.app.workspace.getLeaf().openFile(deck.scheduledNotes[index].note); - return; + const noteChoserMap = { + due: async () => { + if (deck.newNotes.length > 0) { + const index = this.data.settings.openRandomNote + ? Math.floor(Math.random() * deck.newNotes.length) + : 0; + await this.app.workspace.getLeaf().openFile(deck.newNotes[index]); + return; + } + }, + new: async () => { + if (deck.dueNotesCount > 0) { + const index = this.data.settings.openRandomNote + ? Math.floor(Math.random() * deck.dueNotesCount) + : 0; + await this.app.workspace.getLeaf().openFile(deck.scheduledNotes[index].note); + return; + } + } } - if (deck.newNotes.length > 0) { - const index = this.data.settings.openRandomNote - ? Math.floor(Math.random() * deck.newNotes.length) - : 0; - this.app.workspace.getLeaf().openFile(deck.newNotes[index]); - return; + if (this.data.settings.autoNextNewNote) { + await noteChooserMap.new(); + await noteChooserMap.due(); + } else { + await noteChooserMap.due(); + await noteChooserMap.new(); } new Notice(t("ALL_CAUGHT_UP")); diff --git a/src/settings.ts b/src/settings.ts index 3622e73c..cd9595d3 100644 --- a/src/settings.ts +++ b/src/settings.ts @@ -31,6 +31,7 @@ export interface SRSettings { noteFoldersToIgnore: string[]; openRandomNote: boolean; autoNextNote: boolean; + autoNextNewNote: boolean; disableFileMenuReviewOptions: boolean; maxNDaysNotesReviewQueue: number; // UI preferences @@ -75,6 +76,7 @@ export const DEFAULT_SETTINGS: SRSettings = { noteFoldersToIgnore: [], openRandomNote: false, autoNextNote: false, + autoNextNewNote: false, disableFileMenuReviewOptions: false, maxNDaysNotesReviewQueue: 365, // UI settings @@ -574,6 +576,13 @@ export class SRSettingTab extends PluginSettingTab { }), ); + new Setting(containerEl).setName(t("AUTO_NEXT_NEW_NOTE")).addToggle((toggle) => + toggle.setValue(this.plugin.data.settings.autoNextNewNote).onChange(async (value) => { + this.plugin.data.settings.autoNextNewNote = value; + await this.plugin.savePluginData(); + }), + ); + new Setting(containerEl) .setName(t("DISABLE_FILE_MENU_REVIEW_OPTIONS")) .setDesc(t("DISABLE_FILE_MENU_REVIEW_OPTIONS_DESC")) From a167f8f740e5cd9bdf44205e93a92760193d4b89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20=27Matti=27=20H=C3=A4hnel?= Date: Mon, 25 Mar 2024 08:36:13 +0200 Subject: [PATCH 2/2] Fix typo in noteChooserMap --- src/main.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.ts b/src/main.ts index d807da51..98e94cb0 100644 --- a/src/main.ts +++ b/src/main.ts @@ -756,7 +756,7 @@ export default class SRPlugin extends Plugin { this.lastSelectedReviewDeck = deckKey; const deck = this.reviewDecks[deckKey]; - const noteChoserMap = { + const noteChooserMap = { due: async () => { if (deck.newNotes.length > 0) { const index = this.data.settings.openRandomNote @@ -774,8 +774,8 @@ export default class SRPlugin extends Plugin { await this.app.workspace.getLeaf().openFile(deck.scheduledNotes[index].note); return; } - } - } + }, + }; if (this.data.settings.autoNextNewNote) { await noteChooserMap.new();