From 562cef32614e06a0e40958ef4845185f9ea7a8ad Mon Sep 17 00:00:00 2001 From: Jakub <106778416+MarekZegare4@users.noreply.github.com> Date: Tue, 9 Jun 2026 17:19:06 +0200 Subject: [PATCH] fix(NearbyScreen): show "?" for contacts with no timestamp in TIME filter MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit lastmod == 0 produced age = 0 → displayed as "0s"; now shows "?" instead. Co-Authored-By: Claude Sonnet 4.6 --- examples/companion_radio/ui-new/NearbyScreen.h | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/examples/companion_radio/ui-new/NearbyScreen.h b/examples/companion_radio/ui-new/NearbyScreen.h index 7c9e2f49..32250950 100644 --- a/examples/companion_radio/ui-new/NearbyScreen.h +++ b/examples/companion_radio/ui-new/NearbyScreen.h @@ -645,10 +645,14 @@ public: char right[10]; if (_filter == FILTER_COUNT - 1) { uint32_t now = rtc_clock.getCurrentTime(); - uint32_t age = (e.lastmod > 0 && now >= e.lastmod) ? now - e.lastmod : 0; - if (age < 60) snprintf(right, sizeof(right), "%us", age); - else if (age < 3600) snprintf(right, sizeof(right), "%um", age / 60); - else snprintf(right, sizeof(right), "%uh", age / 3600); + if (e.lastmod == 0 || now < e.lastmod) { + snprintf(right, sizeof(right), "?"); + } else { + uint32_t age = now - e.lastmod; + if (age < 60) snprintf(right, sizeof(right), "%us", age); + else if (age < 3600) snprintf(right, sizeof(right), "%um", age / 60); + else snprintf(right, sizeof(right), "%uh", age / 3600); + } } else { if (e.dist_km >= 0.0f) geo::fmtDist(right, sizeof(right), e.dist_km, useImperial()); else strncpy(right, "?GPS", sizeof(right));