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{}
|
attributeViewRelationsLock = sync.Mutex{}
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetSrcAvIDs(destAvID string, excludeSelfAv bool) []string {
|
func GetSrcAvIDs(destAvID string) []string {
|
||||||
attributeViewRelationsLock.Lock()
|
attributeViewRelationsLock.Lock()
|
||||||
defer attributeViewRelationsLock.Unlock()
|
defer attributeViewRelationsLock.Unlock()
|
||||||
|
|
||||||
|
@ -41,10 +41,6 @@ func GetSrcAvIDs(destAvID string, excludeSelfAv bool) []string {
|
||||||
if nil == srcAvIDs {
|
if nil == srcAvIDs {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if excludeSelfAv {
|
|
||||||
srcAvIDs = gulu.Str.RemoveElem(srcAvIDs, destAvID)
|
|
||||||
}
|
|
||||||
return srcAvIDs
|
return srcAvIDs
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3278,7 +3278,7 @@ func removeAttributeViewBlock(srcIDs []string, avID string, tx *Transaction) (er
|
||||||
|
|
||||||
regenAttrViewGroups(attrView, "force")
|
regenAttrViewGroups(attrView, "force")
|
||||||
|
|
||||||
relatedAvIDs := av.GetSrcAvIDs(avID, true)
|
relatedAvIDs := av.GetSrcAvIDs(avID)
|
||||||
for _, relatedAvID := range relatedAvIDs {
|
for _, relatedAvID := range relatedAvIDs {
|
||||||
ReloadAttrView(relatedAvID)
|
ReloadAttrView(relatedAvID)
|
||||||
}
|
}
|
||||||
|
@ -4352,7 +4352,7 @@ func BatchUpdateAttributeViewCells(tx *Transaction, avID string, values []interf
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
relatedAvIDs := av.GetSrcAvIDs(avID, true)
|
relatedAvIDs := av.GetSrcAvIDs(avID)
|
||||||
for _, relatedAvID := range relatedAvIDs {
|
for _, relatedAvID := range relatedAvIDs {
|
||||||
ReloadAttrView(relatedAvID)
|
ReloadAttrView(relatedAvID)
|
||||||
}
|
}
|
||||||
|
@ -4374,7 +4374,7 @@ func UpdateAttributeViewCell(tx *Transaction, avID, keyID, rowID string, valueDa
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
relatedAvIDs := av.GetSrcAvIDs(avID, true)
|
relatedAvIDs := av.GetSrcAvIDs(avID)
|
||||||
for _, relatedAvID := range relatedAvIDs {
|
for _, relatedAvID := range relatedAvIDs {
|
||||||
ReloadAttrView(relatedAvID)
|
ReloadAttrView(relatedAvID)
|
||||||
}
|
}
|
||||||
|
@ -4565,22 +4565,15 @@ func updateAttributeViewValue(tx *Transaction, attrView *av.AttributeView, keyID
|
||||||
updateTwoWayRelationDestAttrView(attrView, key, val, relationChangeMode, oldRelationBlockIDs)
|
updateTwoWayRelationDestAttrView(attrView, key, val, relationChangeMode, oldRelationBlockIDs)
|
||||||
}
|
}
|
||||||
|
|
||||||
if isUpdatingBlockKey {
|
regenAttrViewGroups(attrView, "force")
|
||||||
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 {
|
for _, relatedAvID := range relatedAvIDs {
|
||||||
destAv, _ := av.ParseAttributeView(relatedAvID)
|
destAv, _ := av.ParseAttributeView(relatedAvID)
|
||||||
if nil == destAv {
|
if nil == destAv {
|
||||||
continue
|
continue
|
||||||
}
|
|
||||||
regenAttrViewGroups(destAv, "force")
|
|
||||||
}
|
}
|
||||||
} else {
|
regenAttrViewGroups(destAv, "force")
|
||||||
regenAttrViewGroups(attrView, keyID)
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -5124,7 +5117,7 @@ func getAttrViewName(attrView *av.AttributeView) string {
|
||||||
func replaceRelationAvValues(avID, previousID, nextID string) (changedSrcAvID []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
|
// 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 {
|
for _, srcAvID := range srcAvIDs {
|
||||||
srcAv, parseErr := av.ParseAttributeView(srcAvID)
|
srcAv, parseErr := av.ParseAttributeView(srcAvID)
|
||||||
changed := false
|
changed := false
|
||||||
|
|
|
@ -1562,7 +1562,7 @@ func upsertAvBlockRel(node *ast.Node) {
|
||||||
affectedAvIDs = gulu.Str.RemoveDuplicatedElem(affectedAvIDs)
|
affectedAvIDs = gulu.Str.RemoveDuplicatedElem(affectedAvIDs)
|
||||||
var relatedAvIDs []string
|
var relatedAvIDs []string
|
||||||
for _, avID := range affectedAvIDs {
|
for _, avID := range affectedAvIDs {
|
||||||
relatedAvIDs = append(relatedAvIDs, av.GetSrcAvIDs(avID, true)...)
|
relatedAvIDs = append(relatedAvIDs, av.GetSrcAvIDs(avID)...)
|
||||||
}
|
}
|
||||||
affectedAvIDs = append(affectedAvIDs, relatedAvIDs...)
|
affectedAvIDs = append(affectedAvIDs, relatedAvIDs...)
|
||||||
affectedAvIDs = gulu.Str.RemoveDuplicatedElem(affectedAvIDs)
|
affectedAvIDs = gulu.Str.RemoveDuplicatedElem(affectedAvIDs)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue