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

This commit is contained in:
Liang Ding 2022-12-10 22:17:17 +08:00
parent 7b2f1a0efc
commit ae4272eafb
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
2 changed files with 25 additions and 0 deletions

View file

@ -1247,6 +1247,7 @@ func removeDoc(box *Box, p string) (err error) {
treenode.RemoveBlockTreesByPathPrefix(childrenDir)
sql.RemoveTreePathQueue(box.ID, childrenDir)
RemoveRecentDoc(removeIDs)
if "/" != dir {
others, err := os.ReadDir(filepath.Join(util.DataDir, box.ID, dir))

View file

@ -38,6 +38,30 @@ type RecentDoc struct {
var recentDocLock = sync.Mutex{}
func RemoveRecentDoc(ids []string) {
recentDocLock.Lock()
defer recentDocLock.Unlock()
recentDocs, err := getRecentDocs()
if nil != err {
return
}
ids = gulu.Str.RemoveDuplicatedElem(ids)
for i, doc := range recentDocs {
if gulu.Str.Contains(doc.RootID, ids) {
recentDocs = append(recentDocs[:i], recentDocs[i+1:]...)
break
}
}
err = setRecentDocs(recentDocs)
if nil != err {
return
}
return
}
func SetRecentDoc(doc *RecentDoc) (err error) {
recentDocLock.Lock()
defer recentDocLock.Unlock()