mirror of
https://github.com/MarekWo/mc-webui.git
synced 2026-08-12 03:32:56 +02:00
fix(v2): Fix last_advert timestamps and DM placeholder display
- Sync last_advert from device contacts as Unix timestamp (was missing) - Convert _on_advertisement to store Unix timestamp (was ISO string) - Add _parse_last_advert() to handle both ISO and Unix formats in API - Truncate full pubkey to short prefix in DM placeholder and dropdown Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -207,13 +207,18 @@ class DeviceManager:
|
||||
|
||||
count = 0
|
||||
for pubkey, contact in self.mc.contacts.items():
|
||||
# last_advert from meshcore is Unix timestamp (int) or None
|
||||
last_adv = contact.get('last_advert')
|
||||
last_advert_val = str(int(last_adv)) if last_adv and isinstance(last_adv, (int, float)) and last_adv > 0 else None
|
||||
|
||||
self.db.upsert_contact(
|
||||
public_key=pubkey,
|
||||
name=contact.get('adv_name', ''),
|
||||
type=contact.get('adv_type', 0),
|
||||
type=contact.get('type', 0),
|
||||
flags=contact.get('flags', 0),
|
||||
out_path=contact.get('out_path', ''),
|
||||
out_path_len=contact.get('out_path_len', 0),
|
||||
last_advert=last_advert_val,
|
||||
adv_lat=contact.get('adv_lat'),
|
||||
adv_lon=contact.get('adv_lon'),
|
||||
source='device',
|
||||
@@ -420,7 +425,7 @@ class DeviceManager:
|
||||
type=data.get('adv_type', 0),
|
||||
adv_lat=data.get('adv_lat'),
|
||||
adv_lon=data.get('adv_lon'),
|
||||
last_advert=time.strftime('%Y-%m-%dT%H:%M:%S'),
|
||||
last_advert=str(int(time.time())),
|
||||
source='advert',
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user