Skip to content

Commit

Permalink
Filter due notes when all are scheduled
Browse files Browse the repository at this point in the history
Ignore notes due in the future.

Fixes st3v3nmw#548
  • Loading branch information
carlosgaldino committed May 1, 2024
1 parent 46f2e82 commit 2254709
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions docs/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

[Unreleased]

- Fixed notes selection when all notes are reviewed. [`#548`](https://github.com/st3v3nmw/obsidian-spaced-repetition/issues/548)

#### [1.12.4](https://github.com/st3v3nmw/obsidian-spaced-repetition/compare/1.12.3...1.12.4)

- chore: fix package manager issue in CI [`#939`](https://github.com/st3v3nmw/obsidian-spaced-repetition/pull/939)
Expand Down
8 changes: 5 additions & 3 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -756,11 +756,13 @@ export default class SRPlugin extends Plugin {
this.lastSelectedReviewDeck = deckKey;
const deck = this.reviewDecks[deckKey];

if (deck.dueNotesCount > 0) {
const nowUnix = Date.now();
const dueNotes = deck.scheduledNotes.filter((note) => note.dueUnix <= nowUnix);
if (dueNotes.length > 0) {
const index = this.data.settings.openRandomNote
? Math.floor(Math.random() * deck.dueNotesCount)
? Math.floor(Math.random() * dueNotes.length)
: 0;
await this.app.workspace.getLeaf().openFile(deck.scheduledNotes[index].note);
await this.app.workspace.getLeaf().openFile(dueNotes[index].note);
return;
}

Expand Down

0 comments on commit 2254709

Please sign in to comment.