diff --git a/kernel/model/attribute_view.go b/kernel/model/attribute_view.go index 5428024f4..bacd17bdc 100644 --- a/kernel/model/attribute_view.go +++ b/kernel/model/attribute_view.go @@ -45,7 +45,7 @@ func GetBlockAttributeViewKeys(blockID string) (ret []*BlockAttributeViewKeys) { waitForSyncingStorages() ret = []*BlockAttributeViewKeys{} - attrs := GetBlockAttrs(blockID) + attrs := GetBlockAttrsWithoutWaitWriting(blockID) avs := attrs[av.NodeAttrNameAvs] if "" == avs { return @@ -102,7 +102,7 @@ func GetBlockAttributeViewKeys(blockID string) (ret []*BlockAttributeViewKeys) { kv.Values[0].Created = av.NewFormattedValueCreated(time.Now().UnixMilli(), 0, av.CreatedFormatNone) } case av.KeyTypeUpdated: - ial := GetBlockAttrs(blockID) + ial := GetBlockAttrsWithoutWaitWriting(blockID) updatedStr := ial["updated"] updated, parseErr := time.ParseInLocation("20060102150405", updatedStr, time.Local) if nil == parseErr { @@ -122,7 +122,7 @@ func GetBlockAttributeViewKeys(blockID string) (ret []*BlockAttributeViewKeys) { ial := map[string]string{} block := getRowBlockValue(keyValues) if !block.IsDetached { - ial = GetBlockAttrs(blockID) + ial = GetBlockAttrsWithoutWaitWriting(blockID) } kv.Values[0].Template.Content = renderTemplateCol(ial, kv.Key.Template, keyValues) } @@ -464,7 +464,7 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a ial := map[string]string{} block := row.GetBlockValue() if !block.IsDetached { - ial = GetBlockAttrs(row.ID) + ial = GetBlockAttrsWithoutWaitWriting(row.ID) } content := renderTemplateCol(ial, cell.Value.Template.Content, keyValues) cell.Value.Template.Content = content @@ -481,7 +481,7 @@ func renderAttributeViewTable(attrView *av.AttributeView, view *av.View) (ret *a ial := map[string]string{} block := row.GetBlockValue() if !block.IsDetached { - ial = GetBlockAttrs(row.ID) + ial = GetBlockAttrsWithoutWaitWriting(row.ID) } updatedStr := ial["updated"] if "" == updatedStr { diff --git a/kernel/model/blockial.go b/kernel/model/blockial.go index e8bfa2b47..527cf36d1 100644 --- a/kernel/model/blockial.go +++ b/kernel/model/blockial.go @@ -268,3 +268,28 @@ func GetBlockAttrs(id string) (ret map[string]string) { cache.PutBlockIAL(id, ret) return } + +func GetBlockAttrsWithoutWaitWriting(id string) (ret map[string]string) { + ret = map[string]string{} + if cached := cache.GetBlockIAL(id); nil != cached { + ret = cached + return + } + + tree, err := loadTreeByBlockID(id) + if nil != err { + return + } + + node := treenode.GetNodeInTree(tree, id) + if nil == node { + logging.LogWarnf("block [%s] not found", id) + return + } + + for _, kv := range node.KramdownIAL { + ret[kv[0]] = html.UnescapeAttrVal(kv[1]) + } + cache.PutBlockIAL(id, ret) + return +}