mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-12-17 23:20:13 +01:00
🎨 Backlink count at the doc block title including sub-blocks https://github.com/siyuan-note/siyuan/issues/13791
This commit is contained in:
parent
55538e8b1a
commit
e48680200c
2 changed files with 20 additions and 9 deletions
|
|
@ -151,14 +151,25 @@ func refreshRefCount(rootID, blockID string) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
refCounts := sql.QueryRootChildrenRefCount(bt.RootID)
|
isDoc := bt.ID == bt.RootID
|
||||||
refCount := refCounts[blockID]
|
var rootRefIDs []string
|
||||||
var rootRefCount int
|
var refCount, rootRefCount int
|
||||||
for _, count := range refCounts {
|
refIDs, _ := sql.QueryRefIDsByDefID(bt.ID, isDoc)
|
||||||
rootRefCount += count
|
if isDoc {
|
||||||
|
rootRefIDs = refIDs
|
||||||
|
} else {
|
||||||
|
rootRefIDs, _ = sql.QueryRefIDsByDefID(bt.RootID, true)
|
||||||
}
|
}
|
||||||
refIDs, _, _, _ := GetBlockRefs(blockID, false)
|
refCount = len(refIDs)
|
||||||
util.PushSetDefRefCount(rootID, blockID, refIDs, refCount, rootRefCount)
|
rootRefCount = len(rootRefIDs)
|
||||||
|
var defIDs []string
|
||||||
|
if isDoc {
|
||||||
|
defIDs = sql.QueryChildDefIDsByRootDefID(bt.ID)
|
||||||
|
} else {
|
||||||
|
defIDs = append(defIDs, bt.ID)
|
||||||
|
}
|
||||||
|
|
||||||
|
util.PushSetDefRefCount(rootID, blockID, refIDs, rootRefIDs, defIDs, refCount, rootRefCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
// refreshDynamicRefText 用于刷新块引用的动态锚文本。
|
// refreshDynamicRefText 用于刷新块引用的动态锚文本。
|
||||||
|
|
|
||||||
|
|
@ -271,8 +271,8 @@ func PushSetRefDynamicText(rootID, blockID, defBlockID, refText string) {
|
||||||
BroadcastByType("main", "setRefDynamicText", 0, "", map[string]interface{}{"rootID": rootID, "blockID": blockID, "defBlockID": defBlockID, "refText": refText})
|
BroadcastByType("main", "setRefDynamicText", 0, "", map[string]interface{}{"rootID": rootID, "blockID": blockID, "defBlockID": defBlockID, "refText": refText})
|
||||||
}
|
}
|
||||||
|
|
||||||
func PushSetDefRefCount(rootID, blockID string, refIDs []string, refCount, rootRefCount int) {
|
func PushSetDefRefCount(rootID, blockID string, refIDs, rootRefIDs, defIDs []string, refCount, rootRefCount int) {
|
||||||
BroadcastByType("main", "setDefRefCount", 0, "", map[string]interface{}{"rootID": rootID, "blockID": blockID, "refCount": refCount, "rootRefCount": rootRefCount, "refIDs": refIDs})
|
BroadcastByType("main", "setDefRefCount", 0, "", map[string]interface{}{"rootID": rootID, "blockID": blockID, "refCount": refCount, "rootRefCount": rootRefCount, "refIDs": refIDs, "rootRefIDs": rootRefIDs, "defIDs": defIDs})
|
||||||
}
|
}
|
||||||
|
|
||||||
func PushProtyleLoading(rootID, msg string) {
|
func PushProtyleLoading(rootID, msg string) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue