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

View file

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