From bd8cc6901eb8248a7f806ae28a67052b09de8793 Mon Sep 17 00:00:00 2001 From: "claude[bot]" <209825114+claude[bot]@users.noreply.github.com> Date: Mon, 5 Oct 2026 14:31:37 +0200 Subject: [PATCH] Charts: detect missing older cached prices in _firstUnavailablePrice (#3675) * Charts: detect missing older cached prices in _firstUnavailablePrice Only the newest cached point was checked, so after loading a short range (e.g. 30D or 1H) a longer range (1Y/ALL or 1D) skipped the API fetch and showed only the shorter range's data. Now walk the cached points aligned to the requested precision from the range start and return the first missing slot (before the oldest point, in a gap, or after the newest), tolerating a single missing slot. The existing newest-point check is kept. Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XHSNx4epaJ8hpwuFvWjTmy * Charts: drop comment and logging, use explicit type in _firstUnavailablePrice Co-Authored-By: Claude Opus 5.5 (1M context) Claude-Session: https://claude.ai/code/session_01XHSNx4epaJ8hpwuFvWjTmy --------- Co-authored-by: Claude --- lib/new-ui/model/charts/price_store.dart | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/new-ui/model/charts/price_store.dart b/lib/new-ui/model/charts/price_store.dart index b251f9482..705a17fc7 100644 --- a/lib/new-ui/model/charts/price_store.dart +++ b/lib/new-ui/model/charts/price_store.dart @@ -122,6 +122,22 @@ class PriceStore { return start; } prices.sort(); + + final precisionMs = precision.inMilliseconds; + DateTime expected = start; + for (final price in prices) { + if (price.time.millisecondsSinceEpoch % precisionMs != 0 || price.time.isBefore(start)) { + continue; + } + if (price.time.difference(expected) > precision) { + return expected; + } + expected = price.time.add(precision); + } + if (end.difference(expected) > precision) { + return expected; + } + final last = prices.last; printV("last.time: ${last.time.toIso8601String()} end: ${end.toIso8601String()}"); if (last.time.isAfter(end.subtract(precision)) ||