From a76cfb442c976e852a38d940d64f9ad526918074 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Sat, 24 Dec 2022 10:50:47 +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 | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go index 4adbfc401..c5e4d1a44 100644 --- a/kernel/model/flashcard.go +++ b/kernel/model/flashcard.go @@ -164,6 +164,7 @@ func RemoveFlashcards(deckID string, blockIDs []string) (err error) { } rootIDs = gulu.Str.RemoveDuplicatedElem(rootIDs) + availableDeckIDs := getDeckIDs() trees := map[string]*parse.Tree{} for _, blockID := range blockIDs { rootID := blockRoots[blockID] @@ -187,7 +188,7 @@ func RemoveFlashcards(deckID string, blockIDs []string) (err error) { deckAttrs := node.IALAttr("custom-riff-decks") var deckIDs []string for _, dID := range strings.Split(deckAttrs, ",") { - if dID != deckID { + if dID != deckID && gulu.Str.Contains(dID, availableDeckIDs) { deckIDs = append(deckIDs, dID) } } @@ -434,3 +435,10 @@ func GetDecks() (decks []*riff.Deck) { func getRiffDir() string { return filepath.Join(util.DataDir, "storage", "riff") } + +func getDeckIDs() (deckIDs []string) { + for deckID := range Decks { + deckIDs = append(deckIDs, deckID) + } + return +}