mirror of
https://github.com/siyuan-note/siyuan.git
synced 2025-05-16 17:10:53 +08:00
🎨 Support listing for invalid block references in the search dialog https://github.com/siyuan-note/siyuan/issues/10396
This commit is contained in:
parent
af03c658f0
commit
da9772f003
@ -43,7 +43,7 @@ func listInvalidBlockRefs(c *gin.Context) {
|
||||
page = 1
|
||||
}
|
||||
|
||||
pageSize := 32
|
||||
pageSize := 6
|
||||
if nil != arg["pageSize"] {
|
||||
pageSize = int(arg["pageSize"].(float64))
|
||||
}
|
||||
|
@ -153,6 +153,7 @@ func ListInvalidBlockRefs(page, pageSize int) (ret []*Block, matchedBlockCount,
|
||||
invalidBlockIDs = gulu.Str.RemoveDuplicatedElem(invalidBlockIDs)
|
||||
|
||||
sort.Strings(invalidBlockIDs)
|
||||
allInvalidBlockIDs := invalidBlockIDs
|
||||
|
||||
start := (page - 1) * pageSize
|
||||
end := page * pageSize
|
||||
@ -162,17 +163,26 @@ func ListInvalidBlockRefs(page, pageSize int) (ret []*Block, matchedBlockCount,
|
||||
invalidBlockIDs = invalidBlockIDs[start:end]
|
||||
|
||||
sqlBlocks := sql.GetBlocks(invalidBlockIDs)
|
||||
var tmp []*sql.Block
|
||||
for _, sqlBlock := range sqlBlocks {
|
||||
if nil != sqlBlock {
|
||||
tmp = append(tmp, sqlBlock)
|
||||
}
|
||||
}
|
||||
sqlBlocks = tmp
|
||||
|
||||
ret = fromSQLBlocks(&sqlBlocks, "", 36)
|
||||
if 1 > len(ret) {
|
||||
ret = []*Block{}
|
||||
}
|
||||
matchedBlockCount = len(ret)
|
||||
matchedBlockCount = len(allInvalidBlockIDs)
|
||||
rootCount := map[string]bool{}
|
||||
for _, block := range ret {
|
||||
if nil == block {
|
||||
for _, id := range allInvalidBlockIDs {
|
||||
bt := treenode.GetBlockTree(id)
|
||||
if nil == bt {
|
||||
continue
|
||||
}
|
||||
rootCount[block.RootID] = true
|
||||
rootCount[bt.RootID] = true
|
||||
}
|
||||
matchedRootCount = len(rootCount)
|
||||
pageCount = (matchedBlockCount + pageSize - 1) / pageSize
|
||||
|
Loading…
Reference in New Issue
Block a user