mirror of
https://github.com/Kpa-clawbot/meshcore-analyzer.git
synced 2026-05-29 14:44:12 +00:00
fix: claimed nodes always fetched even if not in current page; auto-sync claimed→favorites
This commit is contained in:
+1
-1
@@ -81,7 +81,7 @@
|
||||
<script src="packets.js?v=1774079160"></script>
|
||||
<script src="map.js?v=1774079160" onerror="console.error('Failed to load:', this.src)"></script>
|
||||
<script src="channels.js?v=1774079160" onerror="console.error('Failed to load:', this.src)"></script>
|
||||
<script src="nodes.js?v=1773961481" onerror="console.error('Failed to load:', this.src)"></script>
|
||||
<script src="nodes.js?v=1773961669" onerror="console.error('Failed to load:', this.src)"></script>
|
||||
<script src="traces.js?v=1774079160" onerror="console.error('Failed to load:', this.src)"></script>
|
||||
<script src="analytics.js?v=1773961035" onerror="console.error('Failed to load:', this.src)"></script>
|
||||
<script src="live.js?v=1773961528" onerror="console.error('Failed to load:', this.src)"></script>
|
||||
|
||||
@@ -5,6 +5,16 @@
|
||||
let nodes = [];
|
||||
const PAYLOAD_TYPES = {0:'Request',1:'Response',2:'Direct Msg',3:'ACK',4:'Advert',5:'Channel Msg',7:'Anon Req',8:'Path',9:'Trace'};
|
||||
|
||||
function syncClaimedToFavorites() {
|
||||
const myNodes = JSON.parse(localStorage.getItem('meshcore-my-nodes') || '[]');
|
||||
const favs = getFavorites();
|
||||
let changed = false;
|
||||
myNodes.forEach(mn => {
|
||||
if (!favs.includes(mn.pubkey)) { favs.push(mn.pubkey); changed = true; }
|
||||
});
|
||||
if (changed) localStorage.setItem('meshcore-favorites', JSON.stringify(favs));
|
||||
}
|
||||
|
||||
let counts = {};
|
||||
let selectedKey = null;
|
||||
let activeTab = 'all';
|
||||
@@ -222,6 +232,23 @@
|
||||
const data = await api('/nodes?' + params);
|
||||
nodes = data.nodes || [];
|
||||
counts = data.counts || {};
|
||||
|
||||
// Ensure claimed nodes are always present even if not in current page
|
||||
const myNodes = JSON.parse(localStorage.getItem('meshcore-my-nodes') || '[]');
|
||||
const existingKeys = new Set(nodes.map(n => n.public_key));
|
||||
const missing = myNodes.filter(mn => !existingKeys.has(mn.pubkey));
|
||||
if (missing.length) {
|
||||
const fetched = await Promise.allSettled(
|
||||
missing.map(mn => api('/nodes/' + encodeURIComponent(mn.pubkey)))
|
||||
);
|
||||
fetched.forEach(r => {
|
||||
if (r.status === 'fulfilled' && r.value && r.value.public_key) nodes.push(r.value);
|
||||
});
|
||||
}
|
||||
|
||||
// Auto-sync claimed → favorites
|
||||
syncClaimedToFavorites();
|
||||
|
||||
renderCounts();
|
||||
renderLeft();
|
||||
} catch (e) {
|
||||
|
||||
Reference in New Issue
Block a user