🎨 Update av

This commit is contained in:
Daniel 2023-07-16 00:08:01 +08:00
parent 3381f1f7d4
commit 073a8bcdd7
No known key found for this signature in database
GPG key ID: 86211BA83DF03017
2 changed files with 97 additions and 52 deletions

View file

@ -722,9 +722,44 @@ func (tx *Transaction) doDelete(operation *Operation) (ret *TxErr) {
if err = tx.writeTree(tree); nil != err {
return
}
syncDelete2AttributeView(node)
return
}
func syncDelete2AttributeView(node *ast.Node) {
avs := node.IALAttr(NodeAttrNameAVs)
if "" == avs {
return
}
avIDs := strings.Split(avs, ",")
for _, avID := range avIDs {
attrView, parseErr := av.ParseAttributeView(avID)
if nil != parseErr {
continue
}
changedAv := false
blockValues := attrView.GetBlockKeyValues()
if nil == blockValues {
continue
}
for i, blockValue := range blockValues.Values {
if blockValue.Block.ID == node.ID {
blockValues.Values = append(blockValues.Values[:i], blockValues.Values[i+1:]...)
changedAv = true
break
}
}
if changedAv {
av.SaveAttributeView(attrView)
util.BroadcastByType("protyle", "refreshAttributeView", 0, "", map[string]interface{}{"id": avID})
}
}
}
func (tx *Transaction) doInsert(operation *Operation) (ret *TxErr) {
var err error
opParentID := operation.ParentID