浏览代码

:bug: 移动文档后打开文档滚动触发动态加载后会关闭页签 Fix https://github.com/siyuan-note/siyuan/issues/7231

Liang Ding 2 年之前
父节点
当前提交
e05ad77aef
共有 1 个文件被更改,包括 3 次插入21 次删除
  1. 3 21
      kernel/treenode/blocktree.go

+ 3 - 21
kernel/treenode/blocktree.go

@@ -147,26 +147,8 @@ func GetBlockTree(id string) (ret *BlockTree) {
 }
 
 func SetBlockTreePath(tree *parse.Tree) {
-	hash := btHash(tree.ID)
-	val, ok := blockTrees.Load(hash)
-	if !ok {
-		val = &btSlice{data: map[string]*BlockTree{}, changed: time.Time{}, m: &sync.Mutex{}}
-		blockTrees.Store(hash, val)
-	}
-
-	slice := val.(*btSlice)
-	slice.m.Lock()
-	slice.data[tree.ID] = &BlockTree{
-		ID:      tree.ID,
-		RootID:  tree.Root.ID,
-		BoxID:   tree.Box,
-		Path:    tree.Path,
-		HPath:   tree.HPath,
-		Updated: tree.Root.IALAttr("updated"),
-		Type:    TypeAbbr(ast.NodeDocument.String()),
-	}
-	slice.m.Unlock()
-	slice.changed = time.Now()
+	RemoveBlockTreesByRootID(tree.ID)
+	IndexBlockTree(tree)
 }
 
 func RemoveBlockTreesByRootID(rootID string) {
@@ -176,7 +158,7 @@ func RemoveBlockTreesByRootID(rootID string) {
 		slice.m.Lock()
 		for _, b := range slice.data {
 			if b.RootID == rootID {
-				ids = append(ids, b.RootID)
+				ids = append(ids, b.ID)
 			}
 		}
 		slice.m.Unlock()