🐛 The sorting of fields in the database attribute panel is unstable https://github.com/siyuan-note/siyuan/issues/12043

This commit is contained in:
Daniel 2024-09-04 11:49:22 +08:00
parent 3ba4eb755f
commit 48162b12a6
No known key found for this signature in database
GPG key ID: 86211BA83DF03017

View file

@ -651,7 +651,7 @@ func GetBlockAttributeViewKeys(blockID string) (ret []*BlockAttributeViewKeys) {
}
// 字段排序
refreshAttrViewKeyIDs(attrView)
refreshAttrViewKeyIDs(attrView, true)
sorts := map[string]int{}
for i, k := range attrView.KeyIDs {
sorts[k] = i
@ -2533,7 +2533,7 @@ func SortAttributeViewKey(avID, keyID, previousKeyID string) (err error) {
return
}
refreshAttrViewKeyIDs(attrView)
refreshAttrViewKeyIDs(attrView, false)
var currentKeyID string
var idx, previousIndex int
@ -2562,7 +2562,7 @@ func SortAttributeViewKey(avID, keyID, previousKeyID string) (err error) {
return
}
func refreshAttrViewKeyIDs(attrView *av.AttributeView) {
func refreshAttrViewKeyIDs(attrView *av.AttributeView, needSave bool) {
// 订正 keyIDs 数据
existKeyIDs := map[string]bool{}
@ -2583,6 +2583,10 @@ func refreshAttrViewKeyIDs(attrView *av.AttributeView) {
}
}
attrView.KeyIDs = tmp
if needSave {
av.SaveAttributeView(attrView)
}
}
func (tx *Transaction) doAddAttrViewColumn(operation *Operation) (ret *TxErr) {