mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-02 19:40:48 +08:00
♻️ Refactor push reload filetree, tag and protyle
This commit is contained in:
parent
ebb74238c9
commit
246efd5938
@ -29,14 +29,14 @@ func reloadTag(c *gin.Context) {
|
|||||||
ret := gulu.Ret.NewResult()
|
ret := gulu.Ret.NewResult()
|
||||||
defer c.JSON(http.StatusOK, ret)
|
defer c.JSON(http.StatusOK, ret)
|
||||||
|
|
||||||
util.PushReloadTag()
|
model.ReloadTag()
|
||||||
}
|
}
|
||||||
|
|
||||||
func reloadFiletree(c *gin.Context) {
|
func reloadFiletree(c *gin.Context) {
|
||||||
ret := gulu.Ret.NewResult()
|
ret := gulu.Ret.NewResult()
|
||||||
defer c.JSON(http.StatusOK, ret)
|
defer c.JSON(http.StatusOK, ret)
|
||||||
|
|
||||||
util.PushReloadFiletree()
|
model.ReloadFiletree()
|
||||||
}
|
}
|
||||||
|
|
||||||
func reloadProtyle(c *gin.Context) {
|
func reloadProtyle(c *gin.Context) {
|
||||||
|
@ -31,7 +31,7 @@ func AutoSpace(rootID string) (err error) {
|
|||||||
|
|
||||||
logging.LogInfof("formatting tree [%s]...", rootID)
|
logging.LogInfof("formatting tree [%s]...", rootID)
|
||||||
util.PushProtyleLoading(rootID, Conf.Language(116))
|
util.PushProtyleLoading(rootID, Conf.Language(116))
|
||||||
defer util.PushReloadProtyle(rootID)
|
defer ReloadProtyle(rootID)
|
||||||
|
|
||||||
FlushTxQueue()
|
FlushTxQueue()
|
||||||
|
|
||||||
|
@ -318,8 +318,8 @@ func RollbackDocHistory(boxID, historyPath string) (err error) {
|
|||||||
if writeErr := indexWriteTreeIndexQueue(tree); nil != writeErr {
|
if writeErr := indexWriteTreeIndexQueue(tree); nil != writeErr {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
util.PushReloadFiletree()
|
ReloadFiletree()
|
||||||
util.PushReloadProtyle(rootID)
|
ReloadProtyle(rootID)
|
||||||
util.PushMsg(Conf.Language(102), 3000)
|
util.PushMsg(Conf.Language(102), 3000)
|
||||||
|
|
||||||
IncSync()
|
IncSync()
|
||||||
|
@ -104,6 +104,14 @@ func refreshDocInfo0(tree *parse.Tree, size uint64) {
|
|||||||
task.AppendAsyncTaskWithDelay(task.ReloadProtyle, 500*time.Millisecond, util.PushReloadDocInfo, docInfo)
|
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) {
|
func ReloadProtyle(rootID string) {
|
||||||
// 刷新关联的引用
|
// 刷新关联的引用
|
||||||
defTree, _ := LoadTreeByBlockID(rootID)
|
defTree, _ := LoadTreeByBlockID(rootID)
|
||||||
|
@ -1692,7 +1692,7 @@ func processSyncMergeResult(exit, byHand bool, mergeResult *dejavu.MergeResult,
|
|||||||
upsertRootIDs, removeRootIDs := incReindex(upserts, removes)
|
upsertRootIDs, removeRootIDs := incReindex(upserts, removes)
|
||||||
needReloadFiletree = !needReloadUI && (needReloadFiletree || 0 < len(upsertRootIDs) || 0 < len(removeRootIDs))
|
needReloadFiletree = !needReloadUI && (needReloadFiletree || 0 < len(upsertRootIDs) || 0 < len(removeRootIDs))
|
||||||
if needReloadFiletree {
|
if needReloadFiletree {
|
||||||
util.PushReloadFiletree()
|
ReloadFiletree()
|
||||||
}
|
}
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
@ -800,7 +800,7 @@ func FindReplace(keyword, replacement string, replaceTypes map[string]bool, ids
|
|||||||
unlinks = append(unlinks, n)
|
unlinks = append(unlinks, n)
|
||||||
}
|
}
|
||||||
|
|
||||||
util.PushReloadTag()
|
ReloadTag()
|
||||||
} else if n.IsTextMarkType("u") {
|
} else if n.IsTextMarkType("u") {
|
||||||
if !replaceTypes["u"] {
|
if !replaceTypes["u"] {
|
||||||
return ast.WalkContinue
|
return ast.WalkContinue
|
||||||
|
@ -136,6 +136,8 @@ const (
|
|||||||
CacheVirtualBlockRef = "task.cache.virtualBlockRef" // 缓存虚拟块引用
|
CacheVirtualBlockRef = "task.cache.virtualBlockRef" // 缓存虚拟块引用
|
||||||
ReloadAttributeView = "task.reload.attributeView" // 重新加载属性视图
|
ReloadAttributeView = "task.reload.attributeView" // 重新加载属性视图
|
||||||
ReloadProtyle = "task.reload.protyle" // 重新加载编辑器
|
ReloadProtyle = "task.reload.protyle" // 重新加载编辑器
|
||||||
|
ReloadTag = "task.reload.tag" // 重新加载标签面板
|
||||||
|
ReloadFiletree = "task.reload.filetree" // 重新加载文档树面板
|
||||||
SetRefDynamicText = "task.ref.setDynamicText" // 设置引用的动态锚文本
|
SetRefDynamicText = "task.ref.setDynamicText" // 设置引用的动态锚文本
|
||||||
SetDefRefCount = "task.def.setRefCount" // 设置定义的引用计数
|
SetDefRefCount = "task.def.setRefCount" // 设置定义的引用计数
|
||||||
UpdateIDs = "task.update.ids" // 更新 ID
|
UpdateIDs = "task.update.ids" // 更新 ID
|
||||||
@ -156,6 +158,8 @@ var uniqueActions = []string{
|
|||||||
AssetContentDatabaseIndexCommit,
|
AssetContentDatabaseIndexCommit,
|
||||||
ReloadAttributeView,
|
ReloadAttributeView,
|
||||||
ReloadProtyle,
|
ReloadProtyle,
|
||||||
|
ReloadTag,
|
||||||
|
ReloadFiletree,
|
||||||
SetRefDynamicText,
|
SetRefDynamicText,
|
||||||
SetDefRefCount,
|
SetDefRefCount,
|
||||||
UpdateIDs,
|
UpdateIDs,
|
||||||
|
Loading…
Reference in New Issue
Block a user