🎨 Improve mirror databases refresh after updating database view layout https://github.com/siyuan-note/siyuan/issues/15233

This commit is contained in:
Daniel 2025-07-08 17:53:13 +08:00
parent e4fb89ee0e
commit 03a10b7c88
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -254,13 +254,26 @@ func ChangeAttrViewLayout(blockID, avID string, layout av.LayoutType) (err error
continue
}
node.AttributeViewType = string(view.LayoutType)
changed := false
attrs := parse.IAL2Map(node.KramdownIAL)
attrs[av.NodeAttrView] = view.ID
err = setNodeAttrs(node, tree, attrs)
if err != nil {
logging.LogWarnf("set node [%s] attrs failed: %s", bID, err)
return
if blockID == bID { // 当前操作的镜像库
attrs[av.NodeAttrView] = view.ID
node.AttributeViewType = string(view.LayoutType)
changed = true
} else {
if view.ID == attrs[av.NodeAttrView] {
// 仅更新和当前操作的镜像库指定的视图相同的镜像库
node.AttributeViewType = string(view.LayoutType)
changed = true
}
}
if changed {
err = setNodeAttrs(node, tree, attrs)
if err != nil {
logging.LogWarnf("set node [%s] attrs failed: %s", bID, err)
return
}
}
}