♻️ Refactor push reload filetree, tag and protyle

This commit is contained in:
Daniel 2025-04-14 22:03:31 +08:00
parent ebb74238c9
commit 246efd5938
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
7 changed files with 19 additions and 7 deletions

View file

@ -31,7 +31,7 @@ func AutoSpace(rootID string) (err error) {
logging.LogInfof("formatting tree [%s]...", rootID)
util.PushProtyleLoading(rootID, Conf.Language(116))
defer util.PushReloadProtyle(rootID)
defer ReloadProtyle(rootID)
FlushTxQueue()

View file

@ -318,8 +318,8 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {
if writeErr := indexWriteTreeIndexQueue(tree); nil != writeErr {
return
}
util.PushReloadFiletree()
util.PushReloadProtyle(rootID)
ReloadFiletree()
ReloadProtyle(rootID)
util.PushMsg(Conf.Language(102), 3000)
IncSync()

View file

@ -104,6 +104,14 @@ func refreshDocInfo0(tree *parse.Tree, size uint64) {
task.AppendAsyncTaskWithDelay(task.ReloadProtyle, 500*time.Millisecond, util.PushReloadDocInfo, docInfo)
}
func ReloadFiletree() {
task.AppendAsyncTaskWithDelay(task.ReloadFiletree, 200*time.Millisecond, util.PushReloadFiletree)
}
func ReloadTag() {
task.AppendAsyncTaskWithDelay(task.ReloadTag, 200*time.Millisecond, util.PushReloadTag)
}
func ReloadProtyle(rootID string) {
// 刷新关联的引用
defTree, _ := LoadTreeByBlockID(rootID)

View file

@ -1692,7 +1692,7 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
upsertRootIDs, removeRootIDs := incReindex(upserts, removes)
needReloadFiletree = !needReloadUI && (needReloadFiletree || 0 < len(upsertRootIDs) || 0 < len(removeRootIDs))
if needReloadFiletree {
util.PushReloadFiletree()
ReloadFiletree()
}
go func() {

View file

@ -800,7 +800,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
unlinks = append(unlinks, n)
}
util.PushReloadTag()
ReloadTag()
} else if n.IsTextMarkType("u") {
if !replaceTypes["u"] {
return ast.WalkContinue