Skip to content

Commit

Permalink
🎨 Improve block update time filling #12182
Browse files Browse the repository at this point in the history
  • Loading branch information
88250 committed Aug 4, 2024
1 parent 3cbb613 commit 27c19ba
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion kernel/model/transaction.go
Original file line number Diff line number Diff line change
Expand Up @@ -1253,13 +1253,32 @@ func refreshUpdated(node *ast.Node) {
}

func createdUpdated(node *ast.Node) {
// 补全子节点的更新时间 Improve block update time filling https://github.com/siyuan-note/siyuan/issues/12182
ast.Walk(node, func(n *ast.Node, entering bool) ast.WalkStatus {
if !entering || !n.IsBlock() || ast.NodeKramdownBlockIAL == n.Type {
return ast.WalkContinue
}

updated := n.IALAttr("updated")
if "" == updated && ast.IsNodeIDPattern(n.ID) {
created := util.TimeFromID(n.ID)
updated = created
if updated < created {
updated = created
}

n.SetIALAttr("updated", updated)
}
return ast.WalkContinue
})

created := util.TimeFromID(node.ID)
updated := node.IALAttr("updated")
if "" == updated {
updated = created
}
if updated < created {
updated = created // 复制粘贴块后创建时间小于更新时间 https://github.com/siyuan-note/siyuan/issues/3624
updated = created
}
parents := treenode.ParentNodesWithHeadings(node)
for _, parent := range parents { // 更新所有父节点的更新时间字段
Expand Down

0 comments on commit 27c19ba

Please sign in to comment.