diff --git a/kernel/api/riff.go b/kernel/api/riff.go index 39b35d7d1..b6acb176a 100644 --- a/kernel/api/riff.go +++ b/kernel/api/riff.go @@ -36,9 +36,10 @@ func resetRiffCards(c *gin.Context) { return } - typ := arg["type"].(string) // notebook, tree, deck - id := arg["id"].(string) // notebook ID, root ID, deck ID - blockIDsArg := arg["blockIDs"] // 如果不传入 blockIDs (或者传入实参为空数组),则重置所有卡片 + typ := arg["type"].(string) // notebook, tree, deck + id := arg["id"].(string) // notebook ID, root ID, deck ID + deckID := arg["deckID"].(string) // deck ID + blockIDsArg := arg["blockIDs"] // 如果不传入 blockIDs (或者传入实参为空数组),则重置所有卡片 var blockIDs []string if nil != blockIDsArg { for _, blockID := range blockIDsArg.([]interface{}) { @@ -46,7 +47,7 @@ func resetRiffCards(c *gin.Context) { } } - model.ResetFlashcards(typ, id, blockIDs) + model.ResetFlashcards(typ, id, deckID, blockIDs) } func getNotebookRiffCards(c *gin.Context) { diff --git a/kernel/model/block.go b/kernel/model/block.go index f735b153e..863b8edeb 100644 --- a/kernel/model/block.go +++ b/kernel/model/block.go @@ -70,9 +70,14 @@ type RiffCard struct { Reps uint64 `json:"reps"` } -func GetRiffCard(card *fsrs.Card) *RiffCard { +func getRiffCard(card *fsrs.Card) *RiffCard { + due := card.Due + if due.IsZero() { + due = time.Now() + } + return &RiffCard{ - Due: card.Due, + Due: due, Reps: card.Reps, } } diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go index 369f6b4dd..fc88f26bc 100644 --- a/kernel/model/flashcard.go +++ b/kernel/model/flashcard.go @@ -39,7 +39,7 @@ import ( "github.com/siyuan-note/siyuan/kernel/util" ) -func ResetFlashcards(typ, id string, blockIDs []string) { +func ResetFlashcards(typ, id, deckID string, blockIDs []string) { // Support resetting the learning progress of flashcards https://github.com/siyuan-note/siyuan/issues/9564 if 0 < len(blockIDs) { @@ -84,7 +84,7 @@ func ResetFlashcards(typ, id string, blockIDs []string) { } blockIDs = gulu.Str.RemoveDuplicatedElem(blockIDs) - resetFlashcards(id, blockIDs) + resetFlashcards(deckID, blockIDs) } func resetFlashcards(deckID string, blockIDs []string) { @@ -334,7 +334,7 @@ func getCardsBlocks(cards []riff.Card, page int) (blocks []*Block, total, pageCo } b.RiffCardID = cards[i].ID() - b.RiffCard = GetRiffCard(cards[i].(*riff.FSRSCard).C) + b.RiffCard = getRiffCard(cards[i].(*riff.FSRSCard).C) } return }