diff --git a/Model.js b/Model.js index eab29f3..f7f8db4 100644 --- a/Model.js +++ b/Model.js @@ -122,6 +122,17 @@ function fmtGB(v) { return (n >= 100 ? n.toFixed(0) : n.toFixed(1)) + " GB" } +// Lifetime usage for display. The daemon keeps `allTime` as completed days +// only (rolled at local midnight), so today's bytes are added here: otherwise +// ALL-TIME sits unchanged all day and can read below TODAY. Null-safe — a +// missing side counts as 0, both missing stays null. +function lifetimeGB(allTimeGB, todayGB) { + var a = num(allTimeGB) + var t = num(todayGB) + if (a === null && t === null) return null + return (a === null ? 0 : a) + (t === null ? 0 : t) +} + function fmtPct(v, decimals) { var n = num(v) return n === null ? "—" : n.toFixed(decimals === undefined ? 1 : decimals) + "%" diff --git a/Panel.qml b/Panel.qml index 86193c3..7d1ad17 100644 --- a/Panel.qml +++ b/Panel.qml @@ -713,7 +713,8 @@ Panel { Text { width: (parent.width - 2 * parent.spacing) * 0.40 text: root.hasData && s.usage - ? "ALL-TIME ↓ " + Model.fmtGB(s.usage.allTimeDownGB) + " ↑ " + Model.fmtGB(s.usage.allTimeUpGB) + ? "ALL-TIME ↓ " + Model.fmtGB(Model.lifetimeGB(s.usage.allTimeDownGB, s.usage.downGB)) + + " ↑ " + Model.fmtGB(Model.lifetimeGB(s.usage.allTimeUpGB, s.usage.upGB)) : "" textFormat: Text.PlainText elide: Text.ElideRight