🎨 Sort tx queue Undo and then redo after Shift+Enter trigger status exception https://github.com/siyuan-note/siyuan/issues/9178
This commit is contained in:
parent
6ffa2425d2
commit
f77f82258e
2 changed files with 9 additions and 0 deletions
|
@ -53,12 +53,16 @@ func performTransactions(c *gin.Context) {
|
|||
return
|
||||
}
|
||||
|
||||
timestamp := int64(arg["reqId"].(float64))
|
||||
var transactions []*model.Transaction
|
||||
if err = gulu.JSON.UnmarshalJSON(data, &transactions); nil != err {
|
||||
ret.Code = -1
|
||||
ret.Msg = "parses request failed"
|
||||
return
|
||||
}
|
||||
for _, transaction := range transactions {
|
||||
transaction.Timestamp = timestamp
|
||||
}
|
||||
|
||||
model.PerformTransactions(&transactions)
|
||||
|
||||
|
|
|
@ -20,6 +20,7 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
@ -152,6 +153,9 @@ func mergeTx() (ret *Transaction) {
|
|||
func PerformTransactions(transactions *[]*Transaction) {
|
||||
txQueueLock.Lock()
|
||||
txQueue = append(txQueue, *transactions...)
|
||||
sort.Slice(txQueue, func(i, j int) bool {
|
||||
return txQueue[i].Timestamp < txQueue[j].Timestamp
|
||||
})
|
||||
txQueueLock.Unlock()
|
||||
return
|
||||
}
|
||||
|
@ -1101,6 +1105,7 @@ type Operation struct {
|
|||
}
|
||||
|
||||
type Transaction struct {
|
||||
Timestamp int64 `json:"timestamp"`
|
||||
DoOperations []*Operation `json:"doOperations"`
|
||||
UndoOperations []*Operation `json:"undoOperations"`
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue