mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-02-03 14:11:47 +01:00
🎨 Improve recent documents handling 2 (#16908)
* https://ld246.com/article/1769260741412 空间换时间 * https://ld246.com/article/1769260741412 跳过不存在的文档
This commit is contained in:
parent
c1a6206f7b
commit
09da39a676
1 changed files with 6 additions and 21 deletions
|
|
@ -66,11 +66,6 @@ func normalizeRecentDocs(recentDocs []*RecentDoc) []*RecentDoc {
|
|||
}
|
||||
|
||||
if len(deduplicated) <= maxCount {
|
||||
// 清空 Title 和 Icon
|
||||
for _, doc := range deduplicated {
|
||||
doc.Title = ""
|
||||
doc.Icon = ""
|
||||
}
|
||||
return deduplicated
|
||||
}
|
||||
|
||||
|
|
@ -129,9 +124,6 @@ func normalizeRecentDocs(recentDocs []*RecentDoc) []*RecentDoc {
|
|||
|
||||
result := make([]*RecentDoc, 0, len(docMap))
|
||||
for _, doc := range docMap {
|
||||
// 清空 Title 和 Icon
|
||||
doc.Title = ""
|
||||
doc.Icon = ""
|
||||
result = append(result, doc)
|
||||
}
|
||||
|
||||
|
|
@ -386,6 +378,11 @@ func getRecentDocs(sortBy string) (ret []*RecentDoc, err error) {
|
|||
bts := treenode.GetBlockTrees(rootIDs)
|
||||
|
||||
for _, sqlBlock := range sqlBlocks {
|
||||
bt := bts[sqlBlock.ID]
|
||||
if nil == bt {
|
||||
continue
|
||||
}
|
||||
|
||||
// 解析 IAL 获取 icon
|
||||
icon := ""
|
||||
if sqlBlock.IAL != "" {
|
||||
|
|
@ -400,19 +397,7 @@ func getRecentDocs(sortBy string) (ret []*RecentDoc, err error) {
|
|||
}
|
||||
}
|
||||
// 获取文档标题
|
||||
title := ""
|
||||
if bt := bts[sqlBlock.ID]; nil != bt {
|
||||
title = path.Base(bt.HPath)
|
||||
}
|
||||
if title == "" {
|
||||
title = sqlBlock.Content
|
||||
if title == "" {
|
||||
title = sqlBlock.HPath
|
||||
if title == "" {
|
||||
title = sqlBlock.ID
|
||||
}
|
||||
}
|
||||
}
|
||||
title := path.Base(bt.HPath)
|
||||
doc := &RecentDoc{
|
||||
RootID: sqlBlock.ID,
|
||||
Icon: icon,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue