From a767572f8efa3e1c26bc22e5e4f567fbbfe82483 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sat, 24 Dec 2022 10:35:02 +0800 Subject: [PATCH] =?UTF-8?q?:art:=20=E6=94=AF=E6=8C=81=E9=97=B4=E9=9A=94?= =?UTF-8?q?=E5=A4=8D=E4=B9=A0=20https://github.com/siyuan-note/siyuan/issu?= =?UTF-8?q?es/6710?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/flashcard.go | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go index f3a5bf660..4adbfc401 100644 --- a/kernel/model/flashcard.go +++ b/kernel/model/flashcard.go @@ -240,7 +240,6 @@ func AddFlashcards(deckID string, blockIDs []string) (err error) { return } - deck := Decks[deckID] var rootIDs []string blockRoots := map[string]string{} for _, blockID := range blockIDs { @@ -298,14 +297,17 @@ func AddFlashcards(deckID string, blockIDs []string) (err error) { pushBroadcastAttrTransactions(trans) } - for _, blockID := range blockIDs { - cardID := ast.NewNodeID() - deck.AddCard(cardID, blockID) - } - err = deck.Save() - if nil != err { - logging.LogErrorf("save deck [%s] failed: %s", deckID, err) - return + deck := Decks[deckID] + if nil != deck { + for _, blockID := range blockIDs { + cardID := ast.NewNodeID() + deck.AddCard(cardID, blockID) + } + err = deck.Save() + if nil != err { + logging.LogErrorf("save deck [%s] failed: %s", deckID, err) + return + } } return }