From 79fe9ee4a582d45e7e1e3301ec81956f948862bf Mon Sep 17 00:00:00 2001 From: xiety Date: Fri, 24 May 2024 00:55:50 +0300 Subject: [PATCH] Fix for ts-fsrs --- src/tsFsrsCalculator.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/tsFsrsCalculator.ts b/src/tsFsrsCalculator.ts index 3542d5a..5fb5feb 100644 --- a/src/tsFsrsCalculator.ts +++ b/src/tsFsrsCalculator.ts @@ -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 { @@ -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[review].card; - // if (fsrs_card.state == 1) {//learning - // const scheduling_cards = f.repeat(fsrs_card, fsrs_card.due); - // fsrs_card = scheduling_cards[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); }