]> git.giacomolli.uk - onechat/blobdiff - view.go
Check operation context on returned errors
[onechat] / view.go
diff --git a/view.go b/view.go
index 9fcd7d8bf91eff927daa49aa94a2b7d93168339f..2124d3d30ed4b23d801afadbfecba2c23aabf453 100644 (file)
--- a/view.go
+++ b/view.go
@@ -168,6 +168,18 @@ func (v *View) Refresh(node Node) {
        }
 }
 
+// Pending tells if a line of the view is not built yet.
+func (v *View) Pending() bool {
+       for _, line := range v.lines {
+               _, built := v.nodes[line]
+               if !built {
+                       return true
+               }
+       }
+
+       return false
+}
+
 // Render returns the view as the model reads it: one line "id+n|text" for each
 // node inside <chat> tags, with the newlines of the text as spaces.
 func (v *View) Render() string {
@@ -304,7 +316,7 @@ func (v *View) mostDue(tree ViewNodeReader) (int, error) {
 
                built, err := tree.Built(left.level+1, left.index/2)
                if err != nil {
-                       return -1, err
+                       return -1, fmt.Errorf("check parent node: %w", err)
                }
 
                if built {