feat(sync): list all linked devices in Sync table
CI / Build & Test (push) Successful in 4m25s

- getSyncStatus() now iterates pass.base.activeWriters and returns
  linkedDevices: [{ id, isCurrent }] for each writer in the sync group
- Dashboard Linked devices table shows every device: "This device" plus
  "Device 2", "Device 3", etc. with their IDs; rows sorted by id
- Fallback to single "This device" row when activeWriters is missing
This commit is contained in:
Raven Scott
2026-03-15 02:03:37 -04:00
parent 925376a6bd
commit 90613511ed
2 changed files with 29 additions and 3 deletions
+13 -3
View File
@@ -45,10 +45,20 @@ function updateSyncStatus() {
const tbody = $('syncLinkedDevicesTable');
if (card) card.style.display = 'block';
if (tbody) {
const deviceId = response.deviceId || '—';
const syncGroupId = response.syncGroupId || '—';
tbody.innerHTML = '<tr><td>This device</td><td class="mono" style="font-size:12px;">' + escapeHtml(deviceId) + '</td></tr>' +
'<tr><td>Sync group</td><td class="mono" style="font-size:12px;">' + escapeHtml(syncGroupId) + '</td></tr>';
const linkedDevices = Array.isArray(response.linkedDevices) ? response.linkedDevices : [];
if (linkedDevices.length > 0) linkedDevices.sort((a, b) => (a.id || '').localeCompare(b.id || ''));
let rows = '';
if (linkedDevices.length > 0) {
linkedDevices.forEach((d, i) => {
const label = d.isCurrent ? 'This device' : ('Device ' + (i + 1));
rows += '<tr><td>' + escapeHtml(label) + '</td><td class="mono" style="font-size:12px;">' + escapeHtml(d.id || '—') + '</td></tr>';
});
} else {
rows = '<tr><td>This device</td><td class="mono" style="font-size:12px;">' + escapeHtml(response.deviceId || '—') + '</td></tr>';
}
rows += '<tr><td>Sync group</td><td class="mono" style="font-size:12px;">' + escapeHtml(syncGroupId) + '</td></tr>';
tbody.innerHTML = rows;
}
} else {
if (dot) dot.style.background = 'var(--text4)';
+16
View File
@@ -257,9 +257,25 @@ async function getSyncStatus() {
try {
out.deviceId = shortId(pass.writerKey) || null;
out.syncGroupId = shortId(pass.discoveryKey) || null;
out.linkedDevices = [];
const myKeyHex = b4a.toString(pass.writerKey, 'hex');
if (pass.base && pass.base.activeWriters) {
for (const w of pass.base.activeWriters) {
if (!w || !w.core || !w.core.key) continue;
const keyHex = b4a.toString(w.core.key, 'hex');
out.linkedDevices.push({
id: shortId(w.core.key),
isCurrent: keyHex === myKeyHex
});
}
}
if (out.linkedDevices.length === 0 && out.deviceId) {
out.linkedDevices = [{ id: out.deviceId, isCurrent: true }];
}
} catch (e) {
out.deviceId = null;
out.syncGroupId = null;
out.linkedDevices = out.deviceId ? [{ id: out.deviceId, isCurrent: true }] : [];
}
}
return out;