From d28c7d212a6eb3f5d34868ec93dfb745f706af96 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sun, 19 Mar 2023 15:35:59 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E9=97=AA=E5=8D=A1=E5=A4=8D=E4=B9=A0?= =?UTF-8?q?=E6=97=B6=E6=94=AF=E6=8C=81=E8=B7=B3=E8=BF=87=20https://github.?= =?UTF-8?q?com/siyuan-note/siyuan/issues/7697?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/flashcard.go | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go index c040bfc42..622ad8d17 100644 --- a/kernel/model/flashcard.go +++ b/kernel/model/flashcard.go @@ -29,6 +29,7 @@ import ( "github.com/88250/gulu" "github.com/88250/lute/ast" "github.com/88250/lute/parse" + "github.com/open-spaced-repetition/go-fsrs" "github.com/siyuan-note/logging" "github.com/siyuan-note/riff" "github.com/siyuan-note/siyuan/kernel/cache" @@ -634,6 +635,10 @@ func removeFlashcardsByBlockIDs(blockIDs []string, deck *riff.Deck) { } cards := deck.GetCardsByBlockIDs(blockIDs) + if 1 > len(cards) { + return + } + for _, card := range cards { deck.RemoveCard(card.ID()) } @@ -900,11 +905,20 @@ func getDeckDueCards(deck *riff.Deck) (ret []riff.Card) { ret = []riff.Card{} dues := deck.Dues() + newCount := 0 + reviewCount := 0 for _, c := range dues { if nil != skipCardCache[c.ID()] { continue } + fsrsCard := c.Impl().(*fsrs.Card) + if fsrs.New == fsrsCard.State { + newCount++ + } else { + reviewCount++ + } + ret = append(ret, c) } return