mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-09-22 00:20:47 +02:00
🎨 Improve Add to Database
https://github.com/siyuan-note/siyuan/issues/10659
This commit is contained in:
parent
d684bb41b1
commit
dcefed26eb
1 changed files with 29 additions and 43 deletions
|
@ -1263,7 +1263,12 @@ func SearchAttributeView(keyword string, excludeAvIDs []string) (ret []*AvSearch
|
|||
logging.LogErrorf("read directory [%s] failed: %s", avDir, err)
|
||||
return
|
||||
}
|
||||
|
||||
avBlockRels := av.GetBlockRels()
|
||||
if 1 > len(avBlockRels) {
|
||||
return
|
||||
}
|
||||
|
||||
for _, entry := range entries {
|
||||
if entry.IsDir() {
|
||||
continue
|
||||
|
@ -1322,48 +1327,29 @@ func SearchAttributeView(keyword string, excludeAvIDs []string) (ret []*AvSearch
|
|||
if 12 <= len(avSearchTmpResults) {
|
||||
avSearchTmpResults = avSearchTmpResults[:12]
|
||||
}
|
||||
var avIDs []string
|
||||
for _, a := range avSearchTmpResults {
|
||||
avIDs = append(avIDs, a.AvID)
|
||||
}
|
||||
|
||||
var blockIDs []string
|
||||
for _, bIDs := range avBlockRels {
|
||||
blockIDs = append(blockIDs, bIDs...)
|
||||
}
|
||||
blockIDs = gulu.Str.RemoveDuplicatedElem(blockIDs)
|
||||
|
||||
trees := filesys.LoadTrees(blockIDs)
|
||||
hitAttrViews := map[string]bool{}
|
||||
for _, blockID := range blockIDs {
|
||||
tree := trees[blockID]
|
||||
if nil == tree {
|
||||
continue
|
||||
}
|
||||
|
||||
node := treenode.GetNodeInTree(tree, blockID)
|
||||
if nil == node || "" == node.AttributeViewID {
|
||||
continue
|
||||
}
|
||||
|
||||
avID := node.AttributeViewID
|
||||
var existAv *AvSearchTempResult
|
||||
for _, tmpResult := range avSearchTmpResults {
|
||||
if tmpResult.AvID == avID {
|
||||
existAv = tmpResult
|
||||
break
|
||||
for _, tmpResult := range avSearchTmpResults {
|
||||
bIDs := avBlockRels[tmpResult.AvID]
|
||||
var node *ast.Node
|
||||
for _, bID := range bIDs {
|
||||
tree, _ := LoadTreeByBlockID(bID)
|
||||
if nil == tree {
|
||||
continue
|
||||
}
|
||||
|
||||
node = treenode.GetNodeInTree(tree, bID)
|
||||
if nil == node || "" == node.AttributeViewID {
|
||||
continue
|
||||
}
|
||||
|
||||
break
|
||||
}
|
||||
if nil == existAv || gulu.Str.Contains(avID, excludeAvIDs) {
|
||||
|
||||
if nil == node {
|
||||
continue
|
||||
}
|
||||
|
||||
if hitAttrViews[avID] {
|
||||
continue
|
||||
}
|
||||
hitAttrViews[avID] = true
|
||||
|
||||
attrView, _ := av.ParseAttributeView(avID)
|
||||
attrView, _ := av.ParseAttributeView(tmpResult.AvID)
|
||||
if nil == attrView {
|
||||
continue
|
||||
}
|
||||
|
@ -1378,27 +1364,27 @@ func SearchAttributeView(keyword string, excludeAvIDs []string) (ret []*AvSearch
|
|||
hPath = box.Name + hPath
|
||||
}
|
||||
|
||||
name := existAv.AvName
|
||||
name := tmpResult.AvName
|
||||
if "" == name {
|
||||
name = Conf.language(267)
|
||||
}
|
||||
|
||||
parent := &AvSearchResult{
|
||||
AvID: avID,
|
||||
AvName: existAv.AvName,
|
||||
BlockID: blockID,
|
||||
AvID: tmpResult.AvID,
|
||||
AvName: tmpResult.AvName,
|
||||
BlockID: node.ID,
|
||||
HPath: hPath,
|
||||
}
|
||||
ret = append(ret, parent)
|
||||
|
||||
for _, view := range attrView.Views {
|
||||
child := &AvSearchResult{
|
||||
AvID: avID,
|
||||
AvName: existAv.AvName,
|
||||
AvID: tmpResult.AvID,
|
||||
AvName: tmpResult.AvName,
|
||||
ViewName: view.Name,
|
||||
ViewID: view.ID,
|
||||
ViewLayout: view.LayoutType,
|
||||
BlockID: blockID,
|
||||
BlockID: node.ID,
|
||||
HPath: hPath,
|
||||
}
|
||||
parent.Children = append(parent.Children, child)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue