fix(dm): refresh mc.contacts from device on PATH_UPDATE event

The Contact Info dialog showed stale path data (e.g. "Flood" instead of
the discovered route) because auto_update_contacts is OFF and PATH_UPDATE
only sets _contacts_dirty=True without refreshing mc.contacts. The API
then served stale in-memory data even after cache invalidation.

Now ensure_contacts(follow=True) is called on PATH_UPDATE to read fresh
contact data from the device before invalidating cache and emitting the
socket event. PATH_UPDATE events are rare (only on path discovery), so
the serial I/O cost is acceptable unlike advertisements.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
MarekWo
2026-03-28 17:52:41 +01:00
parent 0b3bd1da60
commit 701f6f1197
+8
View File
@@ -761,6 +761,14 @@ class DeviceManager:
)
logger.debug(f"Path update for {pubkey[:8]}...")
# Refresh mc.contacts from device so API returns fresh path data.
# PATH_UPDATE events are rare (only on path discovery), so the
# serial I/O cost is acceptable (unlike advertisements).
try:
await self.mc.ensure_contacts(follow=True)
except Exception as e:
logger.warning(f"Failed to refresh contacts after path update: {e}")
# Invalidate contacts cache so UI gets fresh path data
try:
from app.routes.api import invalidate_contacts_cache