mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-16 14:40:12 +01:00
⚡ Improve database rendering performance after editing https://github.com/siyuan-note/siyuan/issues/16464
Signed-off-by: Daniel <845765@qq.com>
This commit is contained in:
parent
4433372bee
commit
36ac36e30d
3 changed files with 42 additions and 12 deletions
|
|
@ -3548,7 +3548,7 @@ func removeAttributeViewBlock(srcIDs []string, avID string, tx *Transaction) (er
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshRelatedSrcAvs(avID)
|
refreshRelatedSrcAvs(avID, tx)
|
||||||
|
|
||||||
historyDir, err := GetHistoryDir(HistoryOpUpdate)
|
historyDir, err := GetHistoryDir(HistoryOpUpdate)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -4688,7 +4688,7 @@ func replaceAttributeViewBlock0(attrView *av.AttributeView, oldBlockID, newNodeI
|
||||||
content = util.UnescapeHTML(content)
|
content = util.UnescapeHTML(content)
|
||||||
blockVal.Block.Icon, blockVal.Block.Content = icon, content
|
blockVal.Block.Icon, blockVal.Block.Content = icon, content
|
||||||
|
|
||||||
refreshRelatedSrcAvs(avID)
|
refreshRelatedSrcAvs(avID, tx)
|
||||||
} else {
|
} else {
|
||||||
blockVal.Block.ID = ""
|
blockVal.Block.ID = ""
|
||||||
}
|
}
|
||||||
|
|
@ -4950,21 +4950,37 @@ func updateAttributeViewValue(tx *Transaction, attrView *av.AttributeView, keyID
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
refreshRelatedSrcAvs(avID)
|
refreshRelatedSrcAvs(avID, tx)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func refreshRelatedSrcAvs(destAvID string) {
|
func refreshRelatedSrcAvs(destAvID string, tx *Transaction) {
|
||||||
relatedAvIDs := av.GetSrcAvIDs(destAvID)
|
relatedAvIDs := av.GetSrcAvIDs(destAvID)
|
||||||
|
|
||||||
|
var tmp []string
|
||||||
for _, relatedAvID := range relatedAvIDs {
|
for _, relatedAvID := range relatedAvIDs {
|
||||||
destAv, _ := av.ParseAttributeView(relatedAvID)
|
if relatedAvID == destAvID {
|
||||||
if nil == destAv {
|
// 目标和源相同则跳过
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
regenAttrViewGroups(destAv)
|
tmp = append(tmp, relatedAvID)
|
||||||
av.SaveAttributeView(destAv)
|
}
|
||||||
ReloadAttrView(relatedAvID)
|
relatedAvIDs = tmp
|
||||||
|
|
||||||
|
if nil != tx {
|
||||||
|
tx.relatedAvIDs = append(tx.relatedAvIDs, relatedAvIDs...)
|
||||||
|
} else {
|
||||||
|
for _, relatedAvID := range relatedAvIDs {
|
||||||
|
destAv, _ := av.ParseAttributeView(relatedAvID)
|
||||||
|
if nil == destAv {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
regenAttrViewGroups(destAv)
|
||||||
|
av.SaveAttributeView(destAv)
|
||||||
|
ReloadAttrView(relatedAvID)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -392,7 +392,7 @@ func updateAttributeViewBlockText(updatedDefNodes map[string]*ast.Node) {
|
||||||
av.SaveAttributeView(attrView)
|
av.SaveAttributeView(attrView)
|
||||||
ReloadAttrView(avID)
|
ReloadAttrView(avID)
|
||||||
|
|
||||||
refreshRelatedSrcAvs(avID)
|
refreshRelatedSrcAvs(avID, nil)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1924,8 +1924,9 @@ type Transaction struct {
|
||||||
DoOperations []*Operation `json:"doOperations"`
|
DoOperations []*Operation `json:"doOperations"`
|
||||||
UndoOperations []*Operation `json:"undoOperations"`
|
UndoOperations []*Operation `json:"undoOperations"`
|
||||||
|
|
||||||
trees map[string]*parse.Tree // 事务中变更的树
|
trees map[string]*parse.Tree // 事务中变更的树
|
||||||
nodes map[string]*ast.Node // 事务中变更的节点
|
nodes map[string]*ast.Node // 事务中变更的节点
|
||||||
|
relatedAvIDs []string // 事务中变更的属性视图 ID
|
||||||
|
|
||||||
isGlobalAssetsInit bool // 是否初始化过全局资源判断
|
isGlobalAssetsInit bool // 是否初始化过全局资源判断
|
||||||
isGlobalAssets bool // 是否属于全局资源
|
isGlobalAssets bool // 是否属于全局资源
|
||||||
|
|
@ -1968,6 +1969,19 @@ func (tx *Transaction) commit() (err error) {
|
||||||
checkUpsertInUserGuide(tree)
|
checkUpsertInUserGuide(tree)
|
||||||
}
|
}
|
||||||
refreshDynamicRefTexts(tx.nodes, tx.trees)
|
refreshDynamicRefTexts(tx.nodes, tx.trees)
|
||||||
|
|
||||||
|
tx.relatedAvIDs = gulu.Str.RemoveDuplicatedElem(tx.relatedAvIDs)
|
||||||
|
for _, avID := range tx.relatedAvIDs {
|
||||||
|
destAv, _ := av.ParseAttributeView(avID)
|
||||||
|
if nil == destAv {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
regenAttrViewGroups(destAv)
|
||||||
|
av.SaveAttributeView(destAv)
|
||||||
|
ReloadAttrView(avID)
|
||||||
|
}
|
||||||
|
|
||||||
IncSync()
|
IncSync()
|
||||||
tx.state.Store(2)
|
tx.state.Store(2)
|
||||||
tx.m.Unlock()
|
tx.m.Unlock()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue