mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
♻️ Adjust addRiffCards/removeRiffCards implementation to be asynchronous transaction https://github.com/siyuan-note/siyuan/issues/7936
This commit is contained in:
parent
e5143a8474
commit
3e14b4f29c
3 changed files with 58 additions and 104 deletions
|
|
@ -216,13 +216,22 @@ func removeRiffCards(c *gin.Context) {
|
|||
for _, blockID := range blockIDsArg {
|
||||
blockIDs = append(blockIDs, blockID.(string))
|
||||
}
|
||||
err := model.RemoveFlashcardsByBlockIDs(deckID, blockIDs)
|
||||
if nil != err {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
|
||||
transactions := []*model.Transaction{
|
||||
{
|
||||
DoOperations: []*model.Operation{
|
||||
{
|
||||
Action: "removeFlashcards",
|
||||
DeckID: deckID,
|
||||
BlockIDs: blockIDs,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
model.PerformTransactions(&transactions)
|
||||
model.WaitForWritingFiles()
|
||||
|
||||
if "" != deckID {
|
||||
deck := model.Decks[deckID]
|
||||
ret.Data = deckData(deck)
|
||||
|
|
@ -245,13 +254,22 @@ func addRiffCards(c *gin.Context) {
|
|||
for _, blockID := range blockIDsArg {
|
||||
blockIDs = append(blockIDs, blockID.(string))
|
||||
}
|
||||
err := model.AddFlashcards(deckID, blockIDs)
|
||||
if nil != err {
|
||||
ret.Code = -1
|
||||
ret.Msg = err.Error()
|
||||
return
|
||||
|
||||
transactions := []*model.Transaction{
|
||||
{
|
||||
DoOperations: []*model.Operation{
|
||||
{
|
||||
Action: "addFlashcards",
|
||||
DeckID: deckID,
|
||||
BlockIDs: blockIDs,
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
model.PerformTransactions(&transactions)
|
||||
model.WaitForWritingFiles()
|
||||
|
||||
deck := model.Decks[deckID]
|
||||
ret.Data = deckData(deck)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue