🎨 Subdocuments created by the database are not displayed in the doc tree https://github.com/siyuan-note/siyuan/issues/9091

This commit is contained in:
Daniel 2023-09-05 16:42:15 +08:00
parent d6fa43c153
commit 682415ae80
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
4 changed files with 21 additions and 8 deletions

View file

@ -96,7 +96,7 @@ func heading2Doc(c *gin.Context) {
name := path.Base(targetPath)
box := model.Conf.Box(targetNotebook)
files, _, _ := model.ListDocTree(targetNotebook, path.Dir(targetPath), util.SortModeUnassigned, false, model.Conf.FileTree.MaxListCount)
files, _, _ := model.ListDocTree(targetNotebook, path.Dir(targetPath), util.SortModeUnassigned, false, false, model.Conf.FileTree.MaxListCount)
evt := util.NewCmdResult("heading2doc", 0, util.PushModeBroadcast)
evt.Data = map[string]interface{}{
"box": box,
@ -141,7 +141,7 @@ func li2Doc(c *gin.Context) {
name := path.Base(targetPath)
box := model.Conf.Box(targetNotebook)
files, _, _ := model.ListDocTree(targetNotebook, path.Dir(targetPath), util.SortModeUnassigned, false, model.Conf.FileTree.MaxListCount)
files, _, _ := model.ListDocTree(targetNotebook, path.Dir(targetPath), util.SortModeUnassigned, false, false, model.Conf.FileTree.MaxListCount)
evt := util.NewCmdResult("li2doc", 0, util.PushModeBroadcast)
evt.Data = map[string]interface{}{
"box": box,
@ -449,7 +449,7 @@ func createDailyNote(c *gin.Context) {
evt.AppId = app
name := path.Base(p)
files, _, _ := model.ListDocTree(box.ID, path.Dir(p), util.SortModeUnassigned, false, model.Conf.FileTree.MaxListCount)
files, _, _ := model.ListDocTree(box.ID, path.Dir(p), util.SortModeUnassigned, false, false, model.Conf.FileTree.MaxListCount)
evt.Data = map[string]interface{}{
"box": box,
"path": p,
@ -648,8 +648,12 @@ func listDocsByPath(c *gin.Context) {
maxListCount = math.MaxInt
}
}
showHidden := true
if arg["showHidden"] != nil {
showHidden = arg["showHidden"].(bool)
}
files, totals, err := model.ListDocTree(notebook, p, sortMode, flashcard, maxListCount)
files, totals, err := model.ListDocTree(notebook, p, sortMode, flashcard, showHidden, maxListCount)
if nil != err {
ret.Code = -1
ret.Msg = err.Error()
@ -760,7 +764,7 @@ func getDoc(c *gin.Context) {
func pushCreate(box *model.Box, p, treeID string, arg map[string]interface{}) {
evt := util.NewCmdResult("create", 0, util.PushModeBroadcast)
name := path.Base(p)
files, _, _ := model.ListDocTree(box.ID, path.Dir(p), util.SortModeUnassigned, false, model.Conf.FileTree.MaxListCount)
files, _, _ := model.ListDocTree(box.ID, path.Dir(p), util.SortModeUnassigned, false, false, model.Conf.FileTree.MaxListCount)
evt.Data = map[string]interface{}{
"box": box,
"path": p,

View file

@ -111,7 +111,7 @@ func loadTreeNodes(box string, p string, level int) (ret []*ast.Node, err error)
}
func buildBlockChildren(block *Block) (err error) {
files, _, err := ListDocTree(block.Box, block.Path, util.SortModeUnassigned, false, Conf.FileTree.MaxListCount)
files, _, err := ListDocTree(block.Box, block.Path, util.SortModeUnassigned, false, false, Conf.FileTree.MaxListCount)
if nil != err {
return
}

View file

@ -66,6 +66,7 @@ type File struct {
HCtime string `json:"hCtime"`
Sort int `json:"sort"`
SubFileCount int `json:"subFileCount"`
Hidden bool `json:"hidden"`
NewFlashcardCount int `json:"newFlashcardCount"`
DueFlashcardCount int `json:"dueFlashcardCount"`
@ -231,7 +232,7 @@ type FileInfo struct {
isdir bool
}
func ListDocTree(boxID, path string, sortMode int, flashcard bool, maxListCount int) (ret []*File, totals int, err error) {
func ListDocTree(boxID, path string, sortMode int, flashcard, showHidden bool, maxListCount int) (ret []*File, totals int, err error) {
//os.MkdirAll("pprof", 0755)
//cpuProfile, _ := os.Create("pprof/cpu_profile_list_doc_tree")
//pprof.StartCPUProfile(cpuProfile)
@ -290,6 +291,10 @@ func ListDocTree(boxID, path string, sortMode int, flashcard bool, maxListCount
continue
}
if ial := box.docIAL(parentDocPath); nil != ial {
if !showHidden && "true" == ial["custom-hidden"] {
continue
}
doc := box.docFromFileInfo(parentDocFile, ial)
subFiles, err := os.ReadDir(filepath.Join(boxLocalPath, file.path))
if nil == err {
@ -323,6 +328,10 @@ func ListDocTree(boxID, path string, sortMode int, flashcard bool, maxListCount
}
if ial := box.docIAL(file.path); nil != ial {
if !showHidden && "true" == ial["custom-hidden"] {
continue
}
doc := box.docFromFileInfo(file, ial)
if flashcard {

View file

@ -194,7 +194,7 @@ func Mount(boxID string) (alreadyMount bool, err error) {
box.Index()
// 缓存根一级的文档树展开
ListDocTree(box.ID, "/", util.SortModeUnassigned, false, Conf.FileTree.MaxListCount)
ListDocTree(box.ID, "/", util.SortModeUnassigned, false, false, Conf.FileTree.MaxListCount)
treenode.SaveBlockTree(false)
util.ClearPushProgress(100)