Fix expanded packet group observation sorting: group by observer, earliest first

This commit is contained in:
you
2026-03-21 22:22:44 +00:00
parent 1158161e1a
commit c4d6fb7cd3
2 changed files with 16 additions and 1 deletions
+1 -1
View File
@@ -84,7 +84,7 @@
<script src="hop-resolver.js?v=1774126708"></script>
<script src="app.js?v=1774126708"></script>
<script src="home.js?v=1774042199"></script>
<script src="packets.js?v=1774330600"></script>
<script src="packets.js?v=1774330800"></script>
<script src="map.js?v=1774126708" onerror="console.error('Failed to load:', this.src)"></script>
<script src="channels.js?v=1774331200" onerror="console.error('Failed to load:', this.src)"></script>
<script src="nodes.js?v=1774126708" onerror="console.error('Failed to load:', this.src)"></script>
+15
View File
@@ -1216,6 +1216,21 @@
const group = packets.find(p => p.hash === hash);
if (group && data.observations) {
group._children = data.observations.map(o => ({...pkt, ...o, _isObservation: true}));
// Sort: group by observer, earliest-observer first, then by time within each observer
const earliest = {};
for (const c of group._children) {
const obs = c.observer || '';
const t = c.rx_at || c.created_at || '';
if (!earliest[obs] || t < earliest[obs]) earliest[obs] = t;
}
group._children.sort((a, b) => {
const oA = a.observer || '', oB = b.observer || '';
const eA = earliest[oA] || '', eB = earliest[oB] || '';
if (eA !== eB) return eA < eB ? -1 : 1;
if (oA !== oB) return oA < oB ? -1 : 1;
const tA = a.rx_at || a.created_at || '', tB = b.rx_at || b.created_at || '';
return tA < tB ? -1 : tA > tB ? 1 : 0;
});
}
// Resolve any new hops from children
const childHops = new Set();