mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-05 16:28:49 +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
|
|
@ -155,6 +155,7 @@ func PerformTransactions(transactions *[]*Transaction) {
|
|||
|
||||
const (
|
||||
TxErrCodeBlockNotFound = 0
|
||||
TxErrCodeDataIsSyncing = 1
|
||||
TxErrCodeWriteTree = 2
|
||||
TxErrWriteAttributeView = 3
|
||||
)
|
||||
|
|
@ -208,7 +209,11 @@ func performTx(tx *Transaction) (ret *TxErr) {
|
|||
case "unfoldHeading":
|
||||
ret = tx.doUnfoldHeading(op)
|
||||
case "setAttrs":
|
||||
ret = tx.setAttrs(op)
|
||||
ret = tx.doSetAttrs(op)
|
||||
case "addFlashcards":
|
||||
ret = tx.doAddFlashcards(op)
|
||||
case "removeFlashcards":
|
||||
ret = tx.doRemoveFlashcards(op)
|
||||
case "insertAttrViewBlock":
|
||||
ret = tx.doInsertAttrViewBlock(op)
|
||||
case "removeAttrViewBlock":
|
||||
|
|
@ -927,7 +932,7 @@ func (tx *Transaction) doCreate(operation *Operation) (ret *TxErr) {
|
|||
return
|
||||
}
|
||||
|
||||
func (tx *Transaction) setAttrs(operation *Operation) (ret *TxErr) {
|
||||
func (tx *Transaction) doSetAttrs(operation *Operation) (ret *TxErr) {
|
||||
id := operation.ID
|
||||
tree, err := tx.loadTree(id)
|
||||
if nil != err {
|
||||
|
|
@ -968,7 +973,7 @@ func (tx *Transaction) setAttrs(operation *Operation) (ret *TxErr) {
|
|||
}
|
||||
}
|
||||
|
||||
if err = indexWriteJSONQueue(tree); nil != err {
|
||||
if err = tx.writeTree(tree); nil != err {
|
||||
return
|
||||
}
|
||||
cache.PutBlockIAL(id, parse.IAL2Map(node.KramdownIAL))
|
||||
|
|
@ -1007,6 +1012,9 @@ type Operation struct {
|
|||
PreviousID string `json:"previousID"`
|
||||
NextID string `json:"nextID"`
|
||||
RetData interface{} `json:"retData"`
|
||||
BlockIDs []string `json:"blockIDs"`
|
||||
|
||||
DeckID string `json:"deckID"` // 用于添加/删除闪卡
|
||||
|
||||
SrcIDs []string `json:"srcIDs"` // 用于将块拖拽到属性视图中
|
||||
Name string `json:"name"` // 用于属性视图列名
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue