This commit is contained in:
Daniel 2024-03-09 10:58:14 +08:00
parent 42651a23a9
commit 16fd52a74d
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 48 additions and 10 deletions

View file

@ -513,7 +513,7 @@ type Flashcard struct {
NextDues map[riff.Rating]string `json:"nextDues"`
}
func newFlashcard(card riff.Card, blockID, deckID string, now time.Time) *Flashcard {
func newFlashcard(card riff.Card, deckID string, now time.Time) *Flashcard {
nextDues := map[riff.Rating]string{}
for rating, due := range card.NextDues() {
nextDues[rating] = strings.TrimSpace(util.HumanizeDiffTime(due, now, Conf.Lang))
@ -522,7 +522,7 @@ func newFlashcard(card riff.Card, blockID, deckID string, now time.Time) *Flashc
return &Flashcard{
DeckID: deckID,
CardID: card.ID(),
BlockID: blockID,
BlockID: card.BlockID(),
Lapses: card.GetLapses(),
Reps: card.GetReps(),
State: card.GetState(),
@ -572,7 +572,7 @@ func GetNotebookDueFlashcards(boxID string, reviewedCardIDs []string) (ret []*Fl
cards, unreviewedCnt, unreviewedNewCardCnt, unreviewedOldCardCnt := getDeckDueCards(deck, reviewedCardIDs, treeBlockIDs, Conf.Flashcard.NewCardLimit, Conf.Flashcard.ReviewCardLimit, Conf.Flashcard.ReviewMode)
now := time.Now()
for _, card := range cards {
ret = append(ret, newFlashcard(card, card.BlockID(), builtinDeckID, now))
ret = append(ret, newFlashcard(card, builtinDeckID, now))
}
if 1 > len(ret) {
ret = []*Flashcard{}
@ -617,7 +617,7 @@ func GetTreeDueFlashcards(rootID string, reviewedCardIDs []string) (ret []*Flash
cards, unreviewedCnt, unreviewedNewCardCnt, unreviewedOldCardCnt := getDeckDueCards(deck, reviewedCardIDs, treeBlockIDs, newCardLimit, reviewCardLimit, Conf.Flashcard.ReviewMode)
now := time.Now()
for _, card := range cards {
ret = append(ret, newFlashcard(card, card.BlockID(), builtinDeckID, now))
ret = append(ret, newFlashcard(card, builtinDeckID, now))
}
if 1 > len(ret) {
ret = []*Flashcard{}
@ -688,7 +688,7 @@ func getDueFlashcards(deckID string, reviewedCardIDs []string) (ret []*Flashcard
cards, unreviewedCnt, unreviewedNewCardCnt, unreviewedOldCardCnt := getDeckDueCards(deck, reviewedCardIDs, nil, Conf.Flashcard.NewCardLimit, Conf.Flashcard.ReviewCardLimit, Conf.Flashcard.ReviewMode)
now := time.Now()
for _, card := range cards {
ret = append(ret, newFlashcard(card, card.BlockID(), deckID, now))
ret = append(ret, newFlashcard(card, deckID, now))
}
if 1 > len(ret) {
ret = []*Flashcard{}
@ -707,7 +707,7 @@ func getAllDueFlashcards(reviewedCardIDs []string) (ret []*Flashcard, unreviewed
unreviewedNewCardCount += unreviewedNewCardCnt
unreviewedOldCardCount += unreviewedOldCardCnt
for _, card := range cards {
ret = append(ret, newFlashcard(card, card.BlockID(), deck.ID, now))
ret = append(ret, newFlashcard(card, deck.ID, now))
}
}
if 1 > len(ret) {