🎨 API listDocsByPath add an optional parameter maxListCount Fix https://github.com/siyuan-note/siyuan/issues/7993

This commit is contained in:
Liang Ding 2023-04-14 12:00:11 +08:00
parent 0b0712f741
commit ee3138be64
No known key found for this signature in database
GPG key ID: 136F30F901A2231D
4 changed files with 17 additions and 13 deletions

View file

@ -95,7 +95,7 @@ func heading2Doc(c *gin.Context) {
name := path.Base(targetPath)
box := model.Conf.Box(targetNotebook)
files, _, _ := model.ListDocTree(targetNotebook, path.Dir(targetPath), model.Conf.FileTree.Sort, false)
files, _, _ := model.ListDocTree(targetNotebook, path.Dir(targetPath), model.Conf.FileTree.Sort, false, model.Conf.FileTree.MaxListCount)
evt := util.NewCmdResult("heading2doc", 0, util.PushModeBroadcast)
evt.Data = map[string]interface{}{
"box": box,
@ -140,7 +140,7 @@ func li2Doc(c *gin.Context) {
name := path.Base(targetPath)
box := model.Conf.Box(targetNotebook)
files, _, _ := model.ListDocTree(targetNotebook, path.Dir(targetPath), model.Conf.FileTree.Sort, false)
files, _, _ := model.ListDocTree(targetNotebook, path.Dir(targetPath), model.Conf.FileTree.Sort, false, model.Conf.FileTree.MaxListCount)
evt := util.NewCmdResult("li2doc", 0, util.PushModeBroadcast)
evt.Data = map[string]interface{}{
"box": box,
@ -448,7 +448,7 @@ func createDailyNote(c *gin.Context) {
evt.AppId = app
name := path.Base(p)
files, _, _ := model.ListDocTree(box.ID, path.Dir(p), model.Conf.FileTree.Sort, false)
files, _, _ := model.ListDocTree(box.ID, path.Dir(p), model.Conf.FileTree.Sort, false, model.Conf.FileTree.MaxListCount)
evt.Data = map[string]interface{}{
"box": box,
"path": p,
@ -619,14 +619,18 @@ func listDocsByPath(c *gin.Context) {
if arg["flashcard"] != nil {
flashcard = arg["flashcard"].(bool)
}
maxListCount := model.Conf.FileTree.MaxListCount
if arg["maxListCount"] != nil {
maxListCount = int(arg["maxListCount"].(float64))
}
files, totals, err := model.ListDocTree(notebook, p, sortMode, flashcard)
files, totals, err := model.ListDocTree(notebook, p, sortMode, flashcard, maxListCount)
if nil != err {
ret.Code = -1
ret.Msg = err.Error()
return
}
if model.Conf.FileTree.MaxListCount < totals {
if maxListCount < totals {
util.PushMsg(fmt.Sprintf(model.Conf.Language(48), len(files)), 7000)
}
@ -718,7 +722,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), model.Conf.FileTree.Sort, false)
files, _, _ := model.ListDocTree(box.ID, path.Dir(p), model.Conf.FileTree.Sort, false, model.Conf.FileTree.MaxListCount)
evt.Data = map[string]interface{}{
"box": box,
"path": p,