mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 07:00:12 +01:00
🎨 同一个块中引用多个相同块时反链去重 Fix https://github.com/siyuan-note/siyuan/issues/3317
This commit is contained in:
parent
c3f6c389fb
commit
2cfd534bc9
1 changed files with 17 additions and 0 deletions
|
|
@ -170,6 +170,7 @@ func BuildTreeBacklink(id, keyword, mentionKeyword string, beforeLen int) (boxID
|
||||||
|
|
||||||
var links []*Block
|
var links []*Block
|
||||||
refs := sql.QueryRefsByDefID(id, true)
|
refs := sql.QueryRefsByDefID(id, true)
|
||||||
|
refs = removeDuplicatedRefs(refs) // 同一个块中引用多个相同块时反链去重 https://github.com/siyuan-note/siyuan/issues/3317
|
||||||
|
|
||||||
// 为了减少查询,组装好 IDs 后一次查出
|
// 为了减少查询,组装好 IDs 后一次查出
|
||||||
defSQLBlockIDs, refSQLBlockIDs := map[string]bool{}, map[string]bool{}
|
defSQLBlockIDs, refSQLBlockIDs := map[string]bool{}, map[string]bool{}
|
||||||
|
|
@ -269,6 +270,22 @@ func BuildTreeBacklink(id, keyword, mentionKeyword string, beforeLen int) (boxID
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func removeDuplicatedRefs(refs []*sql.Ref) (ret []*sql.Ref) {
|
||||||
|
for _, ref := range refs {
|
||||||
|
contain := false
|
||||||
|
for _, r := range ret {
|
||||||
|
if ref.DefBlockID == r.DefBlockID && ref.BlockID == r.BlockID {
|
||||||
|
contain = true
|
||||||
|
break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if !contain {
|
||||||
|
ret = append(ret, ref)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
func buildTreeBackmention(defSQLBlock *sql.Block, refBlocks []*Block, keyword string, excludeBacklinkIDs *hashset.Set, beforeLen int) (ret []*Block) {
|
func buildTreeBackmention(defSQLBlock *sql.Block, refBlocks []*Block, keyword string, excludeBacklinkIDs *hashset.Set, beforeLen int) (ret []*Block) {
|
||||||
ret = []*Block{}
|
ret = []*Block{}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue