This commit is contained in:
Daniel 2024-07-24 10:52:57 +08:00
parent 916ea08ea9
commit 74c6b9ba00
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -320,8 +320,6 @@ func (tx *Transaction) doMove(operation *Operation) (ret *TxErr) {
headingChildren = treenode.GetHeadingFold(headingChildren)
}
refreshHeadingChildrenUpdated(srcNode, time.Now().Format("20060102150405"))
var srcEmptyList *ast.Node
if ast.NodeListItem == srcNode.Type && srcNode.Parent.FirstChild == srcNode && srcNode.Parent.LastChild == srcNode {
// 列表中唯一的列表项被移除后,该列表就为空了
@ -374,8 +372,6 @@ func (tx *Transaction) doMove(operation *Operation) (ret *TxErr) {
srcEmptyList.Unlink()
}
refreshHeadingChildrenUpdated(srcNode, time.Now().Format("20060102150405"))
refreshUpdated(srcNode)
refreshUpdated(srcTree.Root)
if err = tx.writeTree(srcTree); nil != err {
@ -454,8 +450,6 @@ func (tx *Transaction) doMove(operation *Operation) (ret *TxErr) {
}
}
refreshHeadingChildrenUpdated(srcNode, time.Now().Format("20060102150405"))
refreshUpdated(srcNode)
refreshUpdated(srcTree.Root)
if err = tx.writeTree(srcTree); nil != err {
@ -765,8 +759,6 @@ func (tx *Transaction) doDelete(operation *Operation) (ret *TxErr) {
node.Next.Unlink()
}
refreshHeadingChildrenUpdated(node, time.Now().Format("20060102150405"))
node.Unlink()
if nil != parent && ast.NodeListItem == parent.Type && nil == parent.FirstChild {
// 保持空列表项
@ -1026,8 +1018,6 @@ func (tx *Transaction) doInsert(operation *Operation) (ret *TxErr) {
}
}
refreshHeadingChildrenUpdated(insertedNode, time.Now().Format("20060102150405"))
createdUpdated(insertedNode)
tx.nodes[insertedNode.ID] = insertedNode
if err = tx.writeTree(tree); nil != err {
@ -1129,8 +1119,6 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {
treenode.MoveFoldHeading(updatedNode, oldNode)
}
refreshHeadingChildrenUpdated(oldNode, time.Now().Format("20060102150405"))
cache.PutBlockIAL(updatedNode.ID, parse.IAL2Map(updatedNode.KramdownIAL))
// 替换为新节点
@ -1138,7 +1126,6 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {
oldNode.Unlink()
createdUpdated(updatedNode)
refreshHeadingChildrenUpdated(updatedNode, updatedNode.IALAttr("updated"))
tx.nodes[updatedNode.ID] = updatedNode
if err = tx.writeTree(tree); nil != err {
@ -1151,19 +1138,6 @@ func (tx *Transaction) doUpdate(operation *Operation) (ret *TxErr) {
return
}
func refreshHeadingChildrenUpdated(heading *ast.Node, updated string) {
if nil == heading || ast.NodeHeading != heading.Type {
return
}
// 将非标题块更新为标题块时需要更新下方块的 parent id
// The parent block field of the blocks under the heading block is calculated incorrectly https://github.com/siyuan-note/siyuan/issues/9869
children := treenode.HeadingChildren(heading)
for _, child := range children {
child.SetIALAttr("updated", updated)
}
}
func upsertAvBlockRel(node *ast.Node) {
var avIDs []string
ast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus {