Procházet zdrojové kódy

:art: https://github.com/siyuan-note/siyuan/issues/10884

Daniel před 1 rokem
rodič
revize
de0b64f8ca
2 změnil soubory, kde provedl 15 přidání a 1 odebrání
  1. 6 1
      kernel/model/transaction.go
  2. 9 0
      kernel/util/websocket.go

+ 6 - 1
kernel/model/transaction.go

@@ -1312,10 +1312,15 @@ func (tx *Transaction) commit() (err error) {
 		if err = writeJSONQueue(tree); nil != err {
 		if err = writeJSONQueue(tree); nil != err {
 			return
 			return
 		}
 		}
+
+		var sources []interface{}
+		for _, op := range tx.DoOperations {
+			sources = append(sources, op.Action)
+		}
+		util.PushSaveDoc(tree.ID, "tx", sources)
 	}
 	}
 	refreshDynamicRefTexts(tx.nodes, tx.trees)
 	refreshDynamicRefTexts(tx.nodes, tx.trees)
 	IncSync()
 	IncSync()
-	tx.trees = nil
 	tx.state.Store(2)
 	tx.state.Store(2)
 	tx.m.Unlock()
 	tx.m.Unlock()
 	return
 	return

+ 9 - 0
kernel/util/websocket.go

@@ -220,6 +220,15 @@ func PushReloadDoc(rootID string) {
 	BroadcastByType("main", "reloaddoc", 0, "", rootID)
 	BroadcastByType("main", "reloaddoc", 0, "", rootID)
 }
 }
 
 
+func PushSaveDoc(rootID, typ string, sources interface{}) {
+	data := map[string]interface{}{
+		"rootID":  rootID,
+		"type":    typ,
+		"sources": sources,
+	}
+	BroadcastByType("main", "savedoc", 0, "", data)
+}
+
 func PushProtyleReload(rootID string) {
 func PushProtyleReload(rootID string) {
 	BroadcastByType("protyle", "reload", 0, "", rootID)
 	BroadcastByType("protyle", "reload", 0, "", rootID)
 }
 }