mirror of
https://github.com/MarekZegare4/MeshCore-Solo.git
synced 2026-07-27 23:38:12 +00:00
fix(nearby): live [LOC] senders respect the type filter + sort by shared pos
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 <noreply@anthropic.com>
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user