Browse Source

:art: 支持列出和切换最近打开的文档 https://github.com/siyuan-note/siyuan/issues/3293

Liang Ding 2 years ago
parent
commit
bcf3422080
2 changed files with 4 additions and 3 deletions
  1. 2 1
      kernel/model/box.go
  2. 2 2
      kernel/treenode/blocktree.go

+ 2 - 1
kernel/model/box.go

@@ -350,7 +350,8 @@ func (box *Box) Unindex() {
 	sql.RemoveBoxHash(tx, box.ID)
 	sql.DeleteByBoxTx(tx, box.ID)
 	sql.CommitTx(tx)
-	treenode.RemoveBlockTreesByBoxID(box.ID)
+	ids := treenode.RemoveBlockTreesByBoxID(box.ID)
+	RemoveRecentDoc(ids)
 }
 
 func (box *Box) ListFiles(path string) (ret []*FileInfo) {

+ 2 - 2
kernel/treenode/blocktree.go

@@ -175,11 +175,10 @@ func RemoveBlockTreesByPathPrefix(pathPrefix string) {
 	blockTreesChanged = true
 }
 
-func RemoveBlockTreesByBoxID(boxID string) {
+func RemoveBlockTreesByBoxID(boxID string) (ids []string) {
 	blockTreesLock.Lock()
 	defer blockTreesLock.Unlock()
 
-	var ids []string
 	for _, b := range blockTrees {
 		if b.BoxID == boxID {
 			ids = append(ids, b.ID)
@@ -189,6 +188,7 @@ func RemoveBlockTreesByBoxID(boxID string) {
 		delete(blockTrees, id)
 	}
 	blockTreesChanged = true
+	return
 }
 
 func RemoveBlockTree(id string) {