🎨 Avoid flashcard package data overwriting the cloud when syncing on a new device Fix https://github.com/siyuan-note/siyuan/issues/8024

This commit is contained in:
Liang Ding 2023-04-18 13:36:01 +08:00
parent 2f0d0ac45d
commit 221e5c4be3
No known key found for this signature in database
GPG key ID: 136F30F901A2231D

View file

@ -608,6 +608,20 @@ func (tx *Transaction) doAddFlashcards(operation *Operation) (ret *TxErr) {
deckID := operation.DeckID
blockIDs := operation.BlockIDs
foundDeck := false
for _, deck := range Decks {
if deckID == deck.ID {
foundDeck = true
break
}
}
if !foundDeck {
deck, createErr := createDeck0("Built-in Deck", builtinDeckID)
if nil == createErr {
Decks[deck.ID] = deck
}
}
blockRoots := map[string]string{}
for _, blockID := range blockIDs {
bt := treenode.GetBlockTree(blockID)
@ -713,21 +727,6 @@ func LoadFlashcards() {
Decks[deckID] = deck
}
}
// 支持基于文档复习闪卡 https://github.com/siyuan-note/siyuan/issues/7057
foundBuiltinDeck := false
for _, deck := range Decks {
if builtinDeckID == deck.ID {
foundBuiltinDeck = true
break
}
}
if !foundBuiltinDeck {
deck, createErr := createDeck0("Built-in Deck", builtinDeckID)
if nil == createErr {
Decks[deck.ID] = deck
}
}
}
const builtinDeckID = "20230218211946-2kw8jgx"