Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:art: 支持在 All 卡包中移除闪卡 Fix https://github.com/siyuan-note/siyuan/issues/7425

Liang Ding740761fcc871
diff --git a/kernel/model/flashcard.go b/kernel/model/flashcard.go
index 61d6ba6953..4d55ccd6c8 100644
--- a/kernel/model/flashcard.go
+++ b/kernel/model/flashcard.go
@@ -379,9 +379,11 @@ 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 && gulu.Str.Contains(dID, availableDeckIDs) {
- deckIDs = append(deckIDs, dID)
+ if "" != deckID {
+ for _, dID := range strings.Split(deckAttrs, ",") {
+ if dID != deckID && gulu.Str.Contains(dID, availableDeckIDs) {
+ deckIDs = append(deckIDs, dID)
+ }
}
}
@@ -410,20 +412,32 @@ func RemoveFlashcards(deckID string, blockIDs []string) (err error) {
pushBroadcastAttrTransactions(trans)
}
- deck := Decks[deckID]
- if nil != deck {
- for _, blockID := range blockIDs {
- deck.RemoveCard(blockID)
- }
- err = deck.Save()
- if nil != err {
- logging.LogErrorf("save deck [%s] failed: %s", deckID, err)
- return
+ if "" == deckID { // 支持在 All 卡包中移除闪卡 https://github.com/siyuan-note/siyuan/issues/7425
+ for _, deck := range Decks {
+ removeFlashcard(blockIDs, deck)
}
+ } else {
+ removeFlashcard(blockIDs, Decks[deckID])
}
return
}
+func removeFlashcard(blockIDs []string, deck *riff.Deck) {
+ if nil == deck {
+ logging.LogErrorf("deck is nil")
+ return
+ }
+
+ for _, blockID := range blockIDs {
+ deck.RemoveCard(blockID)
+ }
+
+ err := deck.Save()
+ if nil != err {
+ logging.LogErrorf("save deck [%s] failed: %s", deck.ID, err)
+ }
+}
+
func AddFlashcards(deckID string, blockIDs []string) (err error) {
deckLock.Lock()
defer deckLock.Unlock()