Skip to content

Commit

Permalink
Fix for ts-fsrs
Browse files Browse the repository at this point in the history
  • Loading branch information
xiety committed May 23, 2024
1 parent a223d64 commit 79fe9ee
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions src/tsFsrsCalculator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createEmptyCard, fsrs, generatorParameters, type Grade } from "ts-fsrs";
import { State, createEmptyCard, fsrs, generatorParameters, type Grade } from "ts-fsrs";
import { Card, type IFsrsCalculator } from "./IFsrsCalculator";

export class TsFsrsCalculator implements IFsrsCalculator {
Expand Down Expand Up @@ -32,18 +32,17 @@ export class TsFsrsCalculator implements IFsrsCalculator {
const f = fsrs(generatorParameters({ w: this.w }));

for (const review of reviews) {
const scheduling_cards = f.repeat(fsrs_card, fsrs_card.due);
const date = fsrs_card.due;
const scheduling_cards = f.repeat(fsrs_card, date);
fsrs_card = scheduling_cards[<Grade>review].card;

// if (fsrs_card.state == 1) {//learning
// const scheduling_cards = f.repeat(fsrs_card, fsrs_card.due);
// fsrs_card = scheduling_cards[<Grade>review].card;
// }

const displayDifficulty = this.calcDisplayDifficulty(fsrs_card.difficulty);
const interval = this.calcInterval(this.desiredR, fsrs_card.stability);
const cumulativeInterval = card.cumulativeInterval + interval;

fsrs_card.state = State.Review;
fsrs_card.due = new Date(date.getTime() + interval * 24 * 60 * 60 * 1000);

card = new Card(false, fsrs_card.difficulty, displayDifficulty, fsrs_card.stability, interval, cumulativeInterval, review);
list.push(card);
}
Expand Down

0 comments on commit 79fe9ee

Please sign in to comment.