mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-28 12:28:48 +01:00
🎨 Limit the maximum number of tags listed in the tag panel https://github.com/siyuan-note/siyuan/issues/11071
This commit is contained in:
parent
41f3e066ad
commit
01a3f3e690
6 changed files with 38 additions and 12 deletions
|
|
@ -208,6 +208,7 @@ type Tags []*Tag
|
|||
|
||||
func BuildTags() (ret *Tags) {
|
||||
WaitForWritingFiles()
|
||||
|
||||
if !sql.IsEmptyQueue() {
|
||||
sql.WaitForWritingDatabase()
|
||||
}
|
||||
|
|
@ -220,10 +221,30 @@ func BuildTags() (ret *Tags) {
|
|||
}
|
||||
appendTagChildren(&tags, labels)
|
||||
sortTags(tags)
|
||||
ret = &tags
|
||||
|
||||
var total int
|
||||
tmp := &Tags{}
|
||||
for _, tag := range tags {
|
||||
*tmp = append(*tmp, tag)
|
||||
total += countTag(tag)
|
||||
if Conf.FileTree.MaxListCount < total {
|
||||
util.PushMsg(fmt.Sprintf(Conf.Language(243), Conf.FileTree.MaxListCount), 7000)
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
ret = tmp
|
||||
return
|
||||
}
|
||||
|
||||
func countTag(tag *Tag) int {
|
||||
count := 1
|
||||
for _, child := range tag.tags {
|
||||
count += countTag(child)
|
||||
}
|
||||
return count + tag.Count
|
||||
}
|
||||
|
||||
func sortTags(tags Tags) {
|
||||
switch Conf.Tag.Sort {
|
||||
case util.SortModeNameASC:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue