This commit is contained in:
Liang Ding 2022-12-24 10:35:02 +08:00
parent 9a1a69a3db
commit a767572f8e
No known key found for this signature in database
GPG key ID: 136F30F901A2231D

View file

@ -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
}