From 1f30848d8d7cc849f7a7b2d300b78ac3f2b05bb5 Mon Sep 17 00:00:00 2001 From: Daniel <845765@qq.com> Date: Fri, 6 Sep 2024 10:09:28 +0800 Subject: [PATCH] :art: Improve dynamic anchor text auto-refresh stability https://github.com/siyuan-note/siyuan/issues/8234 --- kernel/model/transaction.go | 2 +- kernel/task/queue.go | 6 ++++-- kernel/util/websocket.go | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/kernel/model/transaction.go b/kernel/model/transaction.go index dbb2bf422..cdcc3aa92 100644 --- a/kernel/model/transaction.go +++ b/kernel/model/transaction.go @@ -1487,7 +1487,7 @@ func refreshDynamicRefTexts(updatedDefNodes map[string]*ast.Node, updatedTrees m // 推送动态锚文本节点刷新 for _, defNode := range changedDefNodes { - task.AppendAsyncTaskWithDelay(task.ReloadProtyleBlock, 200*time.Millisecond, util.PushReloadBlock, refTreeID, n.ID, defNode.id, defNode.refText) + task.AppendAsyncTaskWithDelay(task.SetRefDynamicText, 200*time.Millisecond, util.PushSetRefDynamicText, refTreeID, n.ID, defNode.id, defNode.refText) } return ast.WalkContinue } diff --git a/kernel/task/queue.go b/kernel/task/queue.go index 0cb7a87c1..b9f5099fa 100644 --- a/kernel/task/queue.go +++ b/kernel/task/queue.go @@ -134,7 +134,8 @@ const ( AssetContentDatabaseIndexCommit = "task.asset.database.index.commit" // 资源文件数据库索引提交 CacheVirtualBlockRef = "task.cache.virtualBlockRef" // 缓存虚拟块引用 ReloadAttributeView = "task.reload.attributeView" // 重新加载属性视图 - ReloadProtyleBlock = "task.reload.protyleBlock" // 重载编辑器内容块 + SetRefDynamicText = "task.ref.setDynamicText" // 设置引用的动态锚文本 + SetDefRefCount = "task.def.setRefCount" // 设置定义的引用计数 PushMsg = "task.push.msg" // 推送消息 ) @@ -150,7 +151,8 @@ var uniqueActions = []string{ AssetContentDatabaseIndexFull, AssetContentDatabaseIndexCommit, ReloadAttributeView, - ReloadProtyleBlock, + SetRefDynamicText, + SetDefRefCount, } func ContainIndexTask() bool { diff --git a/kernel/util/websocket.go b/kernel/util/websocket.go index 5d52116aa..ee5792a13 100644 --- a/kernel/util/websocket.go +++ b/kernel/util/websocket.go @@ -258,8 +258,8 @@ func PushProtyleReload(rootID string) { BroadcastByType("protyle", "reload", 0, "", rootID) } -func PushReloadBlock(rootID, blockID, defBlockID, refText string) { - BroadcastByType("protyle", "reloadBlock", 0, "", map[string]interface{}{"rootID": rootID, "blockID": blockID, "defBlockID": defBlockID, "refText": refText}) +func PushSetRefDynamicText(rootID, blockID, defBlockID, refText string) { + BroadcastByType("protyle", "setRefDynamicText", 0, "", map[string]interface{}{"rootID": rootID, "blockID": blockID, "defBlockID": defBlockID, "refText": refText}) } func PushProtyleLoading(rootID, msg string) {