mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 Display the database title on the block superscript https://github.com/siyuan-note/siyuan/issues/10545
This commit is contained in:
parent
f1d2344d96
commit
40006904eb
1 changed files with 31 additions and 22 deletions
|
|
@ -1432,9 +1432,35 @@ func (tx *Transaction) doRemoveAttrViewView(operation *Operation) (ret *TxErr) {
|
||||||
return &TxErr{code: TxErrCodeWriteTree, msg: err.Error(), id: avID}
|
return &TxErr{code: TxErrCodeWriteTree, msg: err.Error(), id: avID}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
trees, nodes := getMirrorBlocksNodes(avID)
|
||||||
|
for _, node := range nodes {
|
||||||
|
attrs := parse.IAL2Map(node.KramdownIAL)
|
||||||
|
blockViewID := attrs[av.NodeAttrView]
|
||||||
|
if blockViewID == viewID {
|
||||||
|
attrs[av.NodeAttrView] = attrView.ViewID
|
||||||
|
oldAttrs, e := setNodeAttrs0(node, attrs)
|
||||||
|
if nil != e {
|
||||||
|
logging.LogErrorf("set node attrs failed: %s", e)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
cache.PutBlockIAL(node.ID, parse.IAL2Map(node.KramdownIAL))
|
||||||
|
pushBroadcastAttrTransactions(oldAttrs, node)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, tree := range trees {
|
||||||
|
if err = indexWriteJSONQueue(tree); nil != err {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
func getMirrorBlocksNodes(avID string) (trees []*parse.Tree, nodes []*ast.Node) {
|
||||||
mirrorBlocks := av.GetMirrorBlockIDs(avID)
|
mirrorBlocks := av.GetMirrorBlockIDs(avID)
|
||||||
mirrorBlockTree := map[string]*parse.Tree{}
|
mirrorBlockTree := map[string]*parse.Tree{}
|
||||||
trees := map[string]*parse.Tree{}
|
treeMap := map[string]*parse.Tree{}
|
||||||
for _, mirrorBlock := range mirrorBlocks {
|
for _, mirrorBlock := range mirrorBlocks {
|
||||||
bt := treenode.GetBlockTree(mirrorBlock)
|
bt := treenode.GetBlockTree(mirrorBlock)
|
||||||
if nil == bt {
|
if nil == bt {
|
||||||
|
|
@ -1449,12 +1475,11 @@ func (tx *Transaction) doRemoveAttrViewView(operation *Operation) (ret *TxErr) {
|
||||||
logging.LogErrorf("load tree by block ID [%s] failed", mirrorBlock)
|
logging.LogErrorf("load tree by block ID [%s] failed", mirrorBlock)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
trees[tree.ID] = tree
|
treeMap[tree.ID] = tree
|
||||||
mirrorBlockTree[mirrorBlock] = tree
|
mirrorBlockTree[mirrorBlock] = tree
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var nodes []*ast.Node
|
|
||||||
for _, mirrorBlock := range mirrorBlocks {
|
for _, mirrorBlock := range mirrorBlocks {
|
||||||
tree := mirrorBlockTree[mirrorBlock]
|
tree := mirrorBlockTree[mirrorBlock]
|
||||||
node := treenode.GetNodeInTree(tree, mirrorBlock)
|
node := treenode.GetNodeInTree(tree, mirrorBlock)
|
||||||
|
|
@ -1462,27 +1487,11 @@ func (tx *Transaction) doRemoveAttrViewView(operation *Operation) (ret *TxErr) {
|
||||||
logging.LogErrorf("get node in tree by block ID [%s] failed", mirrorBlock)
|
logging.LogErrorf("get node in tree by block ID [%s] failed", mirrorBlock)
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
nodes = append(nodes, node)
|
||||||
attrs := parse.IAL2Map(node.KramdownIAL)
|
|
||||||
blockViewID := attrs[av.NodeAttrView]
|
|
||||||
if blockViewID == viewID {
|
|
||||||
attrs[av.NodeAttrView] = attrView.ViewID
|
|
||||||
oldAttrs, e := setNodeAttrs0(node, attrs)
|
|
||||||
if nil != e {
|
|
||||||
logging.LogErrorf("set node attrs failed: %s", e)
|
|
||||||
continue
|
|
||||||
}
|
|
||||||
|
|
||||||
cache.PutBlockIAL(node.ID, parse.IAL2Map(node.KramdownIAL))
|
|
||||||
pushBroadcastAttrTransactions(oldAttrs, node)
|
|
||||||
nodes = append(nodes, node)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, tree := range trees {
|
for _, tree := range treeMap {
|
||||||
if err = indexWriteJSONQueue(tree); nil != err {
|
trees = append(trees, tree)
|
||||||
return
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue