mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
🎨 Improve av
This commit is contained in:
parent
52fe742a8c
commit
94f8fc5b71
3 changed files with 13 additions and 24 deletions
|
@ -16,7 +16,7 @@ var (
|
|||
attributeViewRelationsLock = sync.Mutex{}
|
||||
)
|
||||
|
||||
func GetSrcAvIDs(destAvID string, excludeSelfAv bool) []string {
|
||||
func GetSrcAvIDs(destAvID string) []string {
|
||||
attributeViewRelationsLock.Lock()
|
||||
defer attributeViewRelationsLock.Unlock()
|
||||
|
||||
|
@ -41,10 +41,6 @@ func GetSrcAvIDs(destAvID string, excludeSelfAv bool) []string {
|
|||
if nil == srcAvIDs {
|
||||
return nil
|
||||
}
|
||||
|
||||
if excludeSelfAv {
|
||||
srcAvIDs = gulu.Str.RemoveElem(srcAvIDs, destAvID)
|
||||
}
|
||||
return srcAvIDs
|
||||
}
|
||||
|
||||
|
|
|
@ -3278,7 +3278,7 @@ func removeAttributeViewBlock(srcIDs []string, avID string, tx *Transaction) (er
|
|||
|
||||
regenAttrViewGroups(attrView, "force")
|
||||
|
||||
relatedAvIDs := av.GetSrcAvIDs(avID, true)
|
||||
relatedAvIDs := av.GetSrcAvIDs(avID)
|
||||
for _, relatedAvID := range relatedAvIDs {
|
||||
ReloadAttrView(relatedAvID)
|
||||
}
|
||||
|
@ -4352,7 +4352,7 @@ func BatchUpdateAttributeViewCells(tx *Transaction, avID string, values []interf
|
|||
return
|
||||
}
|
||||
|
||||
relatedAvIDs := av.GetSrcAvIDs(avID, true)
|
||||
relatedAvIDs := av.GetSrcAvIDs(avID)
|
||||
for _, relatedAvID := range relatedAvIDs {
|
||||
ReloadAttrView(relatedAvID)
|
||||
}
|
||||
|
@ -4374,7 +4374,7 @@ func UpdateAttributeViewCell(tx *Transaction, avID, keyID, rowID string, valueDa
|
|||
return
|
||||
}
|
||||
|
||||
relatedAvIDs := av.GetSrcAvIDs(avID, true)
|
||||
relatedAvIDs := av.GetSrcAvIDs(avID)
|
||||
for _, relatedAvID := range relatedAvIDs {
|
||||
ReloadAttrView(relatedAvID)
|
||||
}
|
||||
|
@ -4565,13 +4565,9 @@ func updateAttributeViewValue(tx *Transaction, attrView *av.AttributeView, keyID
|
|||
updateTwoWayRelationDestAttrView(attrView, key, val, relationChangeMode, oldRelationBlockIDs)
|
||||
}
|
||||
|
||||
if isUpdatingBlockKey {
|
||||
relatedAvIDs := av.GetSrcAvIDs(avID, false)
|
||||
if gulu.Str.Contains(avID, relatedAvIDs) {
|
||||
regenAttrViewGroups(attrView, "force")
|
||||
}
|
||||
|
||||
relatedAvIDs = gulu.Str.RemoveElem(relatedAvIDs, avID)
|
||||
relatedAvIDs := av.GetSrcAvIDs(avID)
|
||||
for _, relatedAvID := range relatedAvIDs {
|
||||
destAv, _ := av.ParseAttributeView(relatedAvID)
|
||||
if nil == destAv {
|
||||
|
@ -4579,9 +4575,6 @@ func updateAttributeViewValue(tx *Transaction, attrView *av.AttributeView, keyID
|
|||
}
|
||||
regenAttrViewGroups(destAv, "force")
|
||||
}
|
||||
} else {
|
||||
regenAttrViewGroups(attrView, keyID)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
|
@ -5124,7 +5117,7 @@ func getAttrViewName(attrView *av.AttributeView) string {
|
|||
func replaceRelationAvValues(avID, previousID, nextID string) (changedSrcAvID []string) {
|
||||
// The database relation fields follow the change after the primary key field is changed https://github.com/siyuan-note/siyuan/issues/11117
|
||||
|
||||
srcAvIDs := av.GetSrcAvIDs(avID, true)
|
||||
srcAvIDs := av.GetSrcAvIDs(avID)
|
||||
for _, srcAvID := range srcAvIDs {
|
||||
srcAv, parseErr := av.ParseAttributeView(srcAvID)
|
||||
changed := false
|
||||
|
|
|
@ -1562,7 +1562,7 @@ func upsertAvBlockRel(node *ast.Node) {
|
|||
affectedAvIDs = gulu.Str.RemoveDuplicatedElem(affectedAvIDs)
|
||||
var relatedAvIDs []string
|
||||
for _, avID := range affectedAvIDs {
|
||||
relatedAvIDs = append(relatedAvIDs, av.GetSrcAvIDs(avID, true)...)
|
||||
relatedAvIDs = append(relatedAvIDs, av.GetSrcAvIDs(avID)...)
|
||||
}
|
||||
affectedAvIDs = append(affectedAvIDs, relatedAvIDs...)
|
||||
affectedAvIDs = gulu.Str.RemoveDuplicatedElem(affectedAvIDs)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue