From bcb7eb59d5b3e6704c512022c6aee67c098e4312 Mon Sep 17 00:00:00 2001 From: MarekZegare4 Date: Mon, 22 Jun 2026 13:33:18 +0200 Subject: [PATCH] fix(nearby): live [LOC] senders respect the type filter + sort by shared pos MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit A position-sharing node that isn't a stored contact was appended to the Nearby list regardless of the active type filter, so a companion would show up (and, having a live distance, sort to the top) under the Repeater / Room / Sensor filters. Gate the append on the type filter — a non-contact [LOC] sender is treated as a companion, so it only appears under All/Comp. Also drop the "share must be newer than the advert" guard when overlaying a share onto a stored contact: a [LOC] message is an explicit current position, so it always defines the pin and the distance used for proximity sorting (recency for the time sort stays the most recent of advert/share). Verified: WioTrackerL1_companion_solo_dual builds clean. Co-Authored-By: Claude Opus 4.8 --- .../companion_radio/ui-new/NearbyScreen.h | 20 ++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/examples/companion_radio/ui-new/NearbyScreen.h b/examples/companion_radio/ui-new/NearbyScreen.h index 2b13c9d0..21ccf5e5 100644 --- a/examples/companion_radio/ui-new/NearbyScreen.h +++ b/examples/companion_radio/ui-new/NearbyScreen.h @@ -215,17 +215,19 @@ class NearbyScreen : public UIScreen { if (m >= 0) { Entry& e = _entries[m]; - // Only move the pin if the share is at least as recent as the contact's - // advert position, so a stale share can't override a fresher advert. - if (s.ts >= e.lastmod) { - e.lat_e6 = s.lat_1e6; - e.lon_e6 = s.lon_1e6; - e.dist_km = _own_gps ? geo::haversineKm(_own_lat, _own_lon, s.lat_1e6, s.lon_1e6) : -1.0f; - e.lastmod = s.ts; - } + // A [LOC] share is an explicit "here I am now", so it defines the pin and + // the distance (used for proximity sorting). Recency for the time sort is + // the most recent of the advert and the share. + e.lat_e6 = s.lat_1e6; + e.lon_e6 = s.lon_1e6; + e.dist_km = _own_gps ? geo::haversineKm(_own_lat, _own_lon, s.lat_1e6, s.lon_1e6) : -1.0f; + if (s.ts > e.lastmod) e.lastmod = s.ts; e.is_live = true; e.live_verified = s.verified; - } else if (_count < MAX_NEARBY) { + } else if (_count < MAX_NEARBY && typeMatchesFilter(ADV_TYPE_CHAT, 0, false)) { + // A sender we don't have as a contact: treat it as a companion (the only + // node type that shares position), so the type filter still applies — + // e.g. it must not appear under the Repeater/Room/Sensor filters. Entry& e = _entries[_count++]; memset(&e, 0, sizeof(e)); strncpy(e.name, s.name, sizeof(e.name) - 1);