mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-21 17:10:12 +01:00
This commit is contained in:
parent
b3b67832b0
commit
2abc5561b5
5 changed files with 32 additions and 17 deletions
|
|
@ -71,12 +71,14 @@ func GetDueFlashcards(deckID string) (ret []*Flashcard, err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func RemoveFlashcard(blockID string, deckID string) (err error) {
|
||||
func RemoveFlashcards(deckID string, blockIDs []string) (err error) {
|
||||
deckLock.Lock()
|
||||
deck := Decks[deckID]
|
||||
deckLock.Unlock()
|
||||
|
||||
deck.RemoveCard(blockID)
|
||||
for _, blockID := range blockIDs {
|
||||
deck.RemoveCard(blockID)
|
||||
}
|
||||
err = deck.Save()
|
||||
if nil != err {
|
||||
logging.LogErrorf("save deck [%s] failed: %s", deckID, err)
|
||||
|
|
@ -85,13 +87,15 @@ func RemoveFlashcard(blockID string, deckID string) (err error) {
|
|||
return
|
||||
}
|
||||
|
||||
func AddFlashcard(blockID string, deckID string) (err error) {
|
||||
func AddFlashcards(deckID string, blockIDs []string) (err error) {
|
||||
deckLock.Lock()
|
||||
deck := Decks[deckID]
|
||||
deckLock.Unlock()
|
||||
|
||||
cardID := ast.NewNodeID()
|
||||
deck.AddCard(cardID, blockID)
|
||||
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)
|
||||
|
|
@ -128,10 +132,10 @@ func InitFlashcards() {
|
|||
}
|
||||
}
|
||||
|
||||
func CreateDeck(name string) (err error) {
|
||||
func CreateDeck(name string) (deck *riff.Deck, err error) {
|
||||
riffSavePath := getRiffDir()
|
||||
deckID := ast.NewNodeID()
|
||||
deck, err := riff.LoadDeck(riffSavePath, deckID)
|
||||
deck, err = riff.LoadDeck(riffSavePath, deckID)
|
||||
if nil != err {
|
||||
logging.LogErrorf("load deck [%s] failed: %s", deckID, err)
|
||||
return
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue