From 6afce77b1dc54988ae03b02506986195336547f1 Mon Sep 17 00:00:00 2001 From: Liang Ding Date: Tue, 4 Oct 2022 10:55:54 +0800 Subject: [PATCH] =?UTF-8?q?:bug:=20=E8=81=9A=E7=84=A6=E5=90=8E=E5=8F=8D?= =?UTF-8?q?=E9=93=BE=E9=9D=A2=E6=9D=BF=E6=9C=AA=E8=B7=9F=E9=9A=8F=E8=81=9A?= =?UTF-8?q?=E7=84=A6=E6=98=BE=E7=A4=BA=E5=8F=8D=E9=93=BE=20Fix=20https://g?= =?UTF-8?q?ithub.com/siyuan-note/insider/issues/1079?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- kernel/model/backlink.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/kernel/model/backlink.go b/kernel/model/backlink.go index 546604f2e..44e0649e3 100644 --- a/kernel/model/backlink.go +++ b/kernel/model/backlink.go @@ -306,12 +306,13 @@ func GetBacklink2(id, keyword, mentionKeyword string) (boxID string, backlinks, if nil == sqlBlock { return } + rootID := sqlBlock.RootID boxID = sqlBlock.Box refs := sql.QueryRefsByDefID(id, true) refs = removeDuplicatedRefs(refs) // 同一个块中引用多个相同块时反链去重 https://github.com/siyuan-note/siyuan/issues/3317 - linkRefs, linkRefsCount, excludeBacklinkIDs := buildLinkRefs(id, refs) + linkRefs, linkRefsCount, excludeBacklinkIDs := buildLinkRefs(rootID, refs) tmpBacklinks := toFlatTree(linkRefs, 0, "backlink") for _, l := range tmpBacklinks { l.Blocks = nil @@ -461,6 +462,7 @@ func buildLinkRefs(defRootID string, refs []*sql.Ref) (ret []*Block, refsCount i queryBlockIDs = append(queryBlockIDs, ref.DefBlockID) queryBlockIDs = append(queryBlockIDs, ref.BlockID) } + queryBlockIDs = gulu.Str.RemoveDuplicatedElem(queryBlockIDs) querySQLBlocks := sql.GetBlocks(queryBlockIDs) defSQLBlocksCache := map[string]*sql.Block{} for _, defSQLBlock := range querySQLBlocks {