Fix falsy zero lat/lon bug

This commit is contained in:
Jack Kingsman
2026-02-10 21:09:29 -08:00
parent a1e71922bc
commit a61e271e9a
3 changed files with 12 additions and 11 deletions

View File

@@ -31,9 +31,9 @@ class Contact(BaseModel):
"flags": self.flags,
"out_path": self.last_path or "",
"out_path_len": self.last_path_len,
"adv_lat": self.lat or 0.0,
"adv_lon": self.lon or 0.0,
"last_advert": self.last_advert or 0,
"adv_lat": self.lat if self.lat is not None else 0.0,
"adv_lon": self.lon if self.lon is not None else 0.0,
"last_advert": self.last_advert if self.last_advert is not None else 0,
}
@staticmethod

View File

@@ -51,8 +51,8 @@ class ContactRepository:
if "last_path_len" in contact
else contact.get("out_path_len", -1),
contact.get("last_advert"),
contact.get("lat") or contact.get("adv_lat"),
contact.get("lon") or contact.get("adv_lon"),
contact.get("lat") if contact.get("lat") is not None else contact.get("adv_lat"),
contact.get("lon") if contact.get("lon") is not None else contact.get("adv_lon"),
contact.get("last_seen", int(time.time())),
contact.get("on_radio", False),
contact.get("last_contacted"),
@@ -162,7 +162,7 @@ class ContactRepository:
@staticmethod
async def update_last_contacted(public_key: str, timestamp: int | None = None) -> None:
"""Update the last_contacted timestamp for a contact."""
ts = timestamp or int(time.time())
ts = timestamp if timestamp is not None else int(time.time())
await db.conn.execute(
"UPDATE contacts SET last_contacted = ?, last_seen = ? WHERE public_key = ?",
(ts, ts, public_key.lower()),
@@ -175,7 +175,7 @@ class ContactRepository:
Returns True if a row was updated, False if contact not found.
"""
ts = timestamp or int(time.time())
ts = timestamp if timestamp is not None else int(time.time())
cursor = await db.conn.execute(
"UPDATE contacts SET last_read_at = ? WHERE public_key = ?",
(ts, public_key.lower()),
@@ -266,7 +266,7 @@ class ChannelRepository:
Returns True if a row was updated, False if channel not found.
"""
ts = timestamp or int(time.time())
ts = timestamp if timestamp is not None else int(time.time())
cursor = await db.conn.execute(
"UPDATE channels SET last_read_at = ? WHERE key = ?",
(ts, key.upper()),
@@ -350,7 +350,7 @@ class MessageRepository:
This is used when a repeat/echo of a message arrives via a different route.
Returns the updated list of paths.
"""
ts = received_at or int(time.time())
ts = received_at if received_at is not None else int(time.time())
# Get current paths
cursor = await db.conn.execute("SELECT paths FROM messages WHERE id = ?", (message_id,))
@@ -605,7 +605,7 @@ class RawPacketRepository:
Deduplication is based on the SHA-256 hash of the packet payload
(excluding routing/path information).
"""
ts = timestamp or int(time.time())
ts = timestamp if timestamp is not None else int(time.time())
# Compute payload hash for deduplication
payload = extract_payload(data)

View File

@@ -4,6 +4,7 @@ import type { LatLngBoundsExpression, CircleMarker as LeafletCircleMarker } from
import 'leaflet/dist/leaflet.css';
import type { Contact } from '../types';
import { formatTime } from '../utils/messageParser';
import { isValidLocation } from '../utils/pathUtils';
import { CONTACT_TYPE_REPEATER } from '../types';
interface MapViewProps {
@@ -97,7 +98,7 @@ export function MapView({ contacts, focusedKey }: MapViewProps) {
const mappableContacts = useMemo(() => {
const sevenDaysAgo = Date.now() / 1000 - 7 * 24 * 60 * 60;
return contacts.filter(
(c) => c.lat != null && c.lon != null && c.last_seen != null && c.last_seen > sevenDaysAgo
(c) => isValidLocation(c.lat, c.lon) && c.last_seen != null && c.last_seen > sevenDaysAgo
);
}, [contacts]);