🐛 In some cases, the primary key sorting of the database panel fails https://github.com/siyuan-note/siyuan/issues/11621

This commit is contained in:
Daniel 2024-06-03 11:19:33 +08:00
parent cf5ff5283a
commit 06993bddd5
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -2449,12 +2449,25 @@ func SortAttributeViewKey(avID, keyID, previousKeyID string) (err error) {
return
}
if 1 > len(attrView.KeyIDs) {
for _, keyValues := range attrView.KeyValues {
attrView.KeyIDs = append(attrView.KeyIDs, keyValues.Key.ID)
existKeyIDs := map[string]bool{}
for _, keyValues := range attrView.KeyValues {
existKeyIDs[keyValues.Key.ID] = true
}
for k, _ := range existKeyIDs {
if !gulu.Str.Contains(k, attrView.KeyIDs) {
attrView.KeyIDs = append(attrView.KeyIDs, k)
}
}
var tmp []string
for _, k := range attrView.KeyIDs {
if ok := existKeyIDs[k]; ok {
tmp = append(tmp, k)
}
}
attrView.KeyIDs = tmp
var currentKeyID string
var idx, previousIndex int
for i, k := range attrView.KeyIDs {