mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-08-28 08:34:15 +00:00
fix: sort change fetches observations for all visible groups
When switching to a non-Observer sort, batch-fetches observations for all visible multi-observation groups that haven't been expanded yet. Header rows update immediately without needing manual expand.
This commit is contained in:
+1
-1
@@ -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=1774136941"></script>
|
||||
<script src="packets.js?v=1774137140"></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>
|
||||
|
||||
+16
-3
@@ -472,12 +472,25 @@
|
||||
// Observation sort dropdown
|
||||
const obsSortSel = document.getElementById('fObsSort');
|
||||
obsSortSel.value = obsSortMode;
|
||||
obsSortSel.addEventListener('change', function () {
|
||||
obsSortSel.addEventListener('change', async function () {
|
||||
obsSortMode = this.value;
|
||||
localStorage.setItem('meshcore-obs-sort', obsSortMode);
|
||||
// Re-sort all expanded groups
|
||||
// For non-observer sorts, fetch children for visible groups that don't have them yet
|
||||
if (obsSortMode !== SORT_OBSERVER && groupByHash) {
|
||||
const toFetch = packets.filter(p => p.hash && !p._children && (p.observation_count || 0) > 1);
|
||||
await Promise.all(toFetch.map(async (p) => {
|
||||
try {
|
||||
const data = await api(`/packets/${p.hash}`);
|
||||
if (data?.packet && data.observations) {
|
||||
p._children = data.observations.map(o => ({...data.packet, ...o, _isObservation: true}));
|
||||
p._fetchedData = data;
|
||||
}
|
||||
} catch {}
|
||||
}));
|
||||
}
|
||||
// Re-sort all groups with children
|
||||
for (const p of packets) {
|
||||
if (expandedHashes.has(p.hash) && p._children) sortGroupChildren(p);
|
||||
if (p._children) sortGroupChildren(p);
|
||||
}
|
||||
renderTableRows();
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user