🐛 Remove inconsistent scroll IAL

This commit is contained in:
Liang Ding 2023-05-16 11:11:54 +08:00
parent 8b6abec8e9
commit 56a2c368d9
No known key found for this signature in database
GPG key ID: 136F30F901A2231D

View file

@ -56,6 +56,31 @@ func GetDocInfo(rootID string) (ret *BlockInfo) {
title := tree.Root.IALAttr("title") title := tree.Root.IALAttr("title")
ret = &BlockInfo{ID: rootID, Name: title} ret = &BlockInfo{ID: rootID, Name: title}
ret.IAL = parse.IAL2Map(tree.Root.KramdownIAL) ret.IAL = parse.IAL2Map(tree.Root.KramdownIAL)
scrollData := ret.IAL["scroll"]
if 0 < len(scrollData) {
scroll := map[string]interface{}{}
if parseErr := gulu.JSON.UnmarshalJSON([]byte(scrollData), &scroll); nil != parseErr {
logging.LogWarnf("parse scroll data [%s] failed: %s", scrollData, parseErr)
delete(ret.IAL, "scroll")
} else {
if zoomInId := scroll["zoomInId"]; nil != zoomInId {
if nil == treenode.GetBlockTree(zoomInId.(string)) {
delete(ret.IAL, "scroll")
}
} else {
if startId := scroll["startId"]; nil != startId {
if nil == treenode.GetBlockTree(startId.(string)) {
delete(ret.IAL, "scroll")
}
}
if endId := scroll["endId"]; nil != endId {
if nil == treenode.GetBlockTree(endId.(string)) {
delete(ret.IAL, "scroll")
}
}
}
}
}
ret.RefIDs, _ = sql.QueryRefIDsByDefID(rootID, false) ret.RefIDs, _ = sql.QueryRefIDsByDefID(rootID, false)
ret.RefCount = len(ret.RefIDs) ret.RefCount = len(ret.RefIDs)