diff --git a/docs/changelog.md b/docs/changelog.md index a740e670..9479ea15 100644 --- a/docs/changelog.md +++ b/docs/changelog.md @@ -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) diff --git a/src/main.ts b/src/main.ts index fac52371..412a8379 100644 --- a/src/main.ts +++ b/src/main.ts @@ -761,11 +761,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; }