From f552b17f5380d3d61c84441d27a81336e6f67415 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sat, 18 Feb 2023 23:16:31 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=94=AF=E6=8C=81=E5=9F=BA=E4=BA=8E?= =?UTF-8?q?=E6=96=87=E6=A1=A3=E5=A4=8D=E4=B9=A0=E9=97=AA=E5=8D=A1=20https:?= =?UTF-8?q?//github.com/siyuan-note/siyuan/issues/7057?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/api/riff.go | 7 ------- kernel/model/flashcard.go | 22 +++++++--------------- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/kernel/api/riff.go b/kernel/api/riff.go index 41dcb2475..bdc8c065b 100644 --- a/kernel/api/riff.go +++ b/kernel/api/riff.go @@ -76,13 +76,6 @@ func getTreeRiffDueCards(c *gin.Context) { } rootID := arg["rootID"].(string) - err := model.AddTreeFlashcards(rootID) - if nil != err { - ret.Code = -1 - ret.Msg = err.Error() - return - } - cards, err := model.GetTreeDueFlashcards(rootID) if nil != err { ret.Code = -1 diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go index 542412b50..084f944cb 100644 --- a/kernel/model/flashcard.go +++ b/kernel/model/flashcard.go @@ -143,9 +143,14 @@ func GetTreeDueFlashcards(rootID string) (ret []*Flashcard, err error) { } blockIDs := map[string]bool{} - for n := tree.Root.FirstChild; nil != n; n = n.Next { + ast.Walk(tree.Root, func(n *ast.Node, entering bool) ast.WalkStatus { + if !entering || !n.IsBlock() { + return ast.WalkContinue + } + blockIDs[n.ID] = true - } + return ast.WalkContinue + }) cards := deck.Dues() now := time.Now() @@ -336,19 +341,6 @@ func RemoveFlashcards(deckID string, blockIDs []string) (err error) { return } -func AddTreeFlashcards(rootID string) (err error) { - tree, err := loadTreeByBlockID(rootID) - if nil != err { - return - } - - var blockIDs []string - for n := tree.Root.FirstChild; nil != n; n = n.Next { - blockIDs = append(blockIDs, n.ID) - } - return AddFlashcards(builtinDeckID, blockIDs) -} - func AddFlashcards(deckID string, blockIDs []string) (err error) { deckLock.Lock() defer deckLock.Unlock()