fix(ui): parse getPeerStatuses dict response correctly in CellNetwork
The /api/wireguard/peers/statuses endpoint returns {pubkey: {online,...}}
not {peers: [{public_key,...}]}. The status mapping loop was always
producing an empty statusByKey, making every connected cell show Offline.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -311,9 +311,12 @@ export default function CellNetwork() {
|
||||
try {
|
||||
const { wireguardAPI } = await import('../services/api');
|
||||
const sr = await wireguardAPI.getPeerStatuses();
|
||||
(sr.data?.peers || []).forEach(p => {
|
||||
if (p.public_key) statusByKey[p.public_key] = p;
|
||||
});
|
||||
// API returns {pubkey: {online, last_handshake, ...}} — no .peers wrapper
|
||||
const raw = sr.data || {};
|
||||
const entries = Array.isArray(raw.peers)
|
||||
? raw.peers.map(p => [p.public_key, p])
|
||||
: Object.entries(raw);
|
||||
entries.forEach(([pk, info]) => { if (pk) statusByKey[pk] = info; });
|
||||
} catch {
|
||||
// Status enrichment is best-effort; continue without it
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user