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 {
|
try {
|
||||||
const { wireguardAPI } = await import('../services/api');
|
const { wireguardAPI } = await import('../services/api');
|
||||||
const sr = await wireguardAPI.getPeerStatuses();
|
const sr = await wireguardAPI.getPeerStatuses();
|
||||||
(sr.data?.peers || []).forEach(p => {
|
// API returns {pubkey: {online, last_handshake, ...}} — no .peers wrapper
|
||||||
if (p.public_key) statusByKey[p.public_key] = p;
|
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 {
|
} catch {
|
||||||
// Status enrichment is best-effort; continue without it
|
// Status enrichment is best-effort; continue without it
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user