Skip to content

Commit 246efd5

Browse files
committed
♻️ Refactor push reload filetree, tag and protyle
1 parent ebb7423 commit 246efd5

File tree

7 files changed

+19
-7
lines changed

7 files changed

+19
-7
lines changed

kernel/api/ui.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,14 @@ func reloadTag(c *gin.Context) {
2929
ret := gulu.Ret.NewResult()
3030
defer c.JSON(http.StatusOK, ret)
3131

32-
util.PushReloadTag()
32+
model.ReloadTag()
3333
}
3434

3535
func reloadFiletree(c *gin.Context) {
3636
ret := gulu.Ret.NewResult()
3737
defer c.JSON(http.StatusOK, ret)
3838

39-
util.PushReloadFiletree()
39+
model.ReloadFiletree()
4040
}
4141

4242
func reloadProtyle(c *gin.Context) {

kernel/model/format.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ func AutoSpace(rootID string) (err error) {
3131

3232
logging.LogInfof("formatting tree [%s]...", rootID)
3333
util.PushProtyleLoading(rootID, Conf.Language(116))
34-
defer util.PushReloadProtyle(rootID)
34+
defer ReloadProtyle(rootID)
3535

3636
FlushTxQueue()
3737

kernel/model/history.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {
318318
if writeErr := indexWriteTreeIndexQueue(tree); nil != writeErr {
319319
return
320320
}
321-
util.PushReloadFiletree()
322-
util.PushReloadProtyle(rootID)
321+
ReloadFiletree()
322+
ReloadProtyle(rootID)
323323
util.PushMsg(Conf.Language(102), 3000)
324324

325325
IncSync()

kernel/model/push_reload.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,14 @@ func refreshDocInfo0(tree *parse.Tree, size uint64) {
104104
task.AppendAsyncTaskWithDelay(task.ReloadProtyle, 500*time.Millisecond, util.PushReloadDocInfo, docInfo)
105105
}
106106

107+
func ReloadFiletree() {
108+
task.AppendAsyncTaskWithDelay(task.ReloadFiletree, 200*time.Millisecond, util.PushReloadFiletree)
109+
}
110+
111+
func ReloadTag() {
112+
task.AppendAsyncTaskWithDelay(task.ReloadTag, 200*time.Millisecond, util.PushReloadTag)
113+
}
114+
107115
func ReloadProtyle(rootID string) {
108116
// 刷新关联的引用
109117
defTree, _ := LoadTreeByBlockID(rootID)

kernel/model/repository.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1692,7 +1692,7 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
16921692
upsertRootIDs, removeRootIDs := incReindex(upserts, removes)
16931693
needReloadFiletree = !needReloadUI && (needReloadFiletree || 0 < len(upsertRootIDs) || 0 < len(removeRootIDs))
16941694
if needReloadFiletree {
1695-
util.PushReloadFiletree()
1695+
ReloadFiletree()
16961696
}
16971697

16981698
go func() {

kernel/model/search.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
800800
unlinks = append(unlinks, n)
801801
}
802802

803-
util.PushReloadTag()
803+
ReloadTag()
804804
} else if n.IsTextMarkType("u") {
805805
if !replaceTypes["u"] {
806806
return ast.WalkContinue

kernel/task/queue.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ const (
136136
CacheVirtualBlockRef = "task.cache.virtualBlockRef" // 缓存虚拟块引用
137137
ReloadAttributeView = "task.reload.attributeView" // 重新加载属性视图
138138
ReloadProtyle = "task.reload.protyle" // 重新加载编辑器
139+
ReloadTag = "task.reload.tag" // 重新加载标签面板
140+
ReloadFiletree = "task.reload.filetree" // 重新加载文档树面板
139141
SetRefDynamicText = "task.ref.setDynamicText" // 设置引用的动态锚文本
140142
SetDefRefCount = "task.def.setRefCount" // 设置定义的引用计数
141143
UpdateIDs = "task.update.ids" // 更新 ID
@@ -156,6 +158,8 @@ var uniqueActions = []string{
156158
AssetContentDatabaseIndexCommit,
157159
ReloadAttributeView,
158160
ReloadProtyle,
161+
ReloadTag,
162+
ReloadFiletree,
159163
SetRefDynamicText,
160164
SetDefRefCount,
161165
UpdateIDs,

0 commit comments

Comments
 (0)