🎨 Improve database unbind block https://github.com/siyuan-note/siyuan/issues/11013
This commit is contained in:
parent
58c98ce697
commit
97f8d6c013
1 changed files with 28 additions and 24 deletions
|
@ -1301,18 +1301,20 @@ func unbindAttributeViewBlock(operation *Operation, tx *Transaction) (err error)
|
|||
return
|
||||
}
|
||||
|
||||
keyValues := attrView.GetBlockKeyValues()
|
||||
for _, value := range keyValues.Values {
|
||||
if value.BlockID != operation.ID {
|
||||
continue
|
||||
}
|
||||
for _, keyValues := range attrView.KeyValues {
|
||||
for _, value := range keyValues.Values {
|
||||
if value.BlockID != operation.ID {
|
||||
continue
|
||||
}
|
||||
|
||||
unbindBlockAv(tx, operation.AvID, value.BlockID)
|
||||
value.BlockID = operation.NextID
|
||||
if nil != value.Block {
|
||||
value.Block.ID = operation.NextID
|
||||
if av.KeyTypeBlock == value.Type {
|
||||
unbindBlockAv(tx, operation.AvID, value.BlockID)
|
||||
}
|
||||
value.BlockID = operation.NextID
|
||||
if nil != value.Block {
|
||||
value.Block.ID = operation.NextID
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
|
||||
replacedRowID := false
|
||||
|
@ -2956,25 +2958,27 @@ func replaceAttributeViewBlock(operation *Operation, tx *Transaction) (err error
|
|||
|
||||
for _, keyValues := range attrView.KeyValues {
|
||||
for _, value := range keyValues.Values {
|
||||
if value.BlockID == operation.PreviousID {
|
||||
if value.BlockID != operation.NextID {
|
||||
// 换绑
|
||||
unbindBlockAv(tx, operation.AvID, value.BlockID)
|
||||
}
|
||||
if value.BlockID != operation.PreviousID {
|
||||
continue
|
||||
}
|
||||
|
||||
value.BlockID = operation.NextID
|
||||
if nil != value.Block {
|
||||
value.Block.ID = operation.NextID
|
||||
value.IsDetached = operation.IsDetached
|
||||
if !operation.IsDetached {
|
||||
value.Block.Content = getNodeRefText(node)
|
||||
}
|
||||
}
|
||||
if av.KeyTypeBlock == value.Type && value.BlockID != operation.NextID {
|
||||
// 换绑
|
||||
unbindBlockAv(tx, operation.AvID, value.BlockID)
|
||||
}
|
||||
|
||||
value.BlockID = operation.NextID
|
||||
if av.KeyTypeBlock == value.Type && nil != value.Block {
|
||||
value.Block.ID = operation.NextID
|
||||
value.IsDetached = operation.IsDetached
|
||||
if !operation.IsDetached {
|
||||
bindBlockAv(tx, operation.AvID, operation.NextID)
|
||||
value.Block.Content = getNodeRefText(node)
|
||||
}
|
||||
}
|
||||
|
||||
if av.KeyTypeBlock == value.Type && !operation.IsDetached {
|
||||
bindBlockAv(tx, operation.AvID, operation.NextID)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue