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

Filter due notes when all are scheduled #947

Merged
merged 1 commit into from
Jul 22, 2024
Merged
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
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
Loading