mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-08-06 08:43:17 +02:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user