Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add option to check new notes before due notes #917

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/lang/locale/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
39 changes: 26 additions & 13 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 noteChooserMap = {
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"));
Expand Down
9 changes: 9 additions & 0 deletions src/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export interface SRSettings {
noteFoldersToIgnore: string[];
openRandomNote: boolean;
autoNextNote: boolean;
autoNextNewNote: boolean;
disableFileMenuReviewOptions: boolean;
maxNDaysNotesReviewQueue: number;
// UI preferences
Expand Down Expand Up @@ -75,6 +76,7 @@ export const DEFAULT_SETTINGS: SRSettings = {
noteFoldersToIgnore: [],
openRandomNote: false,
autoNextNote: false,
autoNextNewNote: false,
disableFileMenuReviewOptions: false,
maxNDaysNotesReviewQueue: 365,
// UI settings
Expand Down Expand Up @@ -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"))
Expand Down
Loading