🎨 Automatically refresh database views after deleting/rolling back documents https://github.com/siyuan-note/siyuan/issues/12081

This commit is contained in:
Daniel 2024-09-04 20:15:10 +08:00
parent 4ccf648e57
commit 8fee81c8c1
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
3 changed files with 32 additions and 15 deletions

View file

@ -248,6 +248,7 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {
return
}
var avIDs []string
tree, _ := loadTree(srcPath, util.NewLute())
if nil != tree {
historyDir := strings.TrimPrefix(historyPath, util.HistoryDir+string(os.PathSeparator))
@ -266,8 +267,11 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {
logging.LogErrorf("copy av [%s] failed: %s", srcAvPath, copyErr)
}
}
avIDs = append(avIDs, avNode.AttributeViewID)
}
}
avIDs = gulu.Str.RemoveDuplicatedElem(avIDs)
tree.Box = boxID
tree.Path = filepath.ToSlash(strings.TrimPrefix(destPath, util.DataDir+string(os.PathSeparator)+boxID))
@ -305,6 +309,11 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {
"refText": refText,
}
util.PushEvent(evt)
// 刷新属性视图
for _, avID := range avIDs {
util.PushReloadAttrView(avID)
}
}()
return nil
}