🎨 Limit the maximum number of tags listed in the tag panel https://github.com/siyuan-note/siyuan/issues/11071

This commit is contained in:
Daniel 2024-04-19 20:06:43 +08:00
parent 41f3e066ad
commit 01a3f3e690
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
6 changed files with 38 additions and 12 deletions

View file

@ -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: