Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:bug: Fix AV row icon not updating after set (regression from #18058 ref-text optimization) #18204

Danielc4a0aa7be3b4
diff --git a/kernel/model/blockial.go b/kernel/model/blockial.go
index a653d9db30..28449f22b3 100644
--- a/kernel/model/blockial.go
+++ b/kernel/model/blockial.go
@@ -29,6 +29,7 @@ import (
"github.com/88250/lute/html"
"github.com/88250/lute/parse"
"github.com/araddon/dateparse"
+ "github.com/siyuan-note/siyuan/kernel/av"
"github.com/siyuan-note/siyuan/kernel/cache"
"github.com/siyuan-note/siyuan/kernel/filesys"
"github.com/siyuan-note/siyuan/kernel/sql"
@@ -227,6 +228,11 @@ func setNodeAttrs(node *ast.Node, tree *parse.Tree, nameValues map[string]string
refreshDynamicRefText(node, tree)
}()
}
+ if attrsAffectAvBlock(nameValues) {
+ go func() {
+ updateAttributeViewBlockText(map[string]*ast.Node{node.ID: node})
+ }()
+ }
return
}
@@ -248,6 +254,24 @@ func attrsAffectRefText(nameValues map[string]string) bool {
return false
}
+// attrsAffectAvBlock 判断本次属性变更是否可能影响数据库(属性视图)主键块的显示。
+//
+// 数据库主键块的 icon 和 content 由 getNodeAvBlockText 从块的 icon、name、
+// custom-sy-av-s-text-<avID> 属性派生,这些属性变更时需调用 updateAttributeViewBlockText
+// 同步到 AV JSON,否则数据库视图中显示的图标/内容不会更新。
+func attrsAffectAvBlock(nameValues map[string]string) bool {
+ for name := range nameValues {
+ lowerName := strings.ToLower(name)
+ if "icon" == lowerName || "name" == lowerName {
+ return true
+ }
+ if strings.HasPrefix(lowerName, av.NodeAttrViewStaticText) {
+ return true
+ }
+ }
+ return false
+}
+
func setNodeAttrsWithTx(tx *Transaction, node *ast.Node, tree *parse.Tree, nameValues map[string]string) (err error) {
oldAttrs, err := setNodeAttrs0(node, nameValues, tree.Box)
if err != nil {