Skip to content

Commit

Permalink
Review only due notes
Browse files Browse the repository at this point in the history
This patch fixes the behaviour of determining the next note to only
consider notes that are due. If a note is scheduled in the future, it
won't be picked up for review until it's due.

This is the same patch as st3v3nmw#947.

Fixes st3v3nmw#328.
  • Loading branch information
carlosgaldino committed Sep 23, 2024
1 parent 12b3651 commit 8bd7046
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/note-review-deck.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { t } from "src/lang/helpers";
import { ISRFile } from "src/sr-file";
import { globalDateProvider } from "src/utils/dates";
import { globalRandomNumberProvider } from "src/utils/numbers";

export class SchedNote {
Expand Down Expand Up @@ -81,10 +82,12 @@ export class NoteReviewDeck {
determineNextNote(openRandomNote: boolean): ISRFile {
// Review due notes before new ones
if (this.dueNotesCount > 0) {
const todayUnix: number = globalDateProvider.today.valueOf();
const dueNotes = this.scheduledNotes.filter((note) => note.isDue(todayUnix));
const index = openRandomNote
? globalRandomNumberProvider.getInteger(0, this.dueNotesCount - 1)
? globalRandomNumberProvider.getInteger(0, dueNotes.length - 1)
: 0;
return this.scheduledNotes[index].note;
return dueNotes[index].note;
}

if (this.newNotes.length > 0) {
Expand Down

0 comments on commit 8bd7046

Please sign in to comment.