fix: claimed (My Mesh) nodes sort to top, then favorites, then rest

This commit is contained in:
you
2026-03-19 22:36:33 +00:00
parent 341dd1fec3
commit 0ee2830f59
2 changed files with 7 additions and 2 deletions
+1 -1
View File
@@ -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=1773959690" onerror="console.error('Failed to load:', this.src)"></script>
<script src="nodes.js?v=1773959793" 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=1774079160" onerror="console.error('Failed to load:', this.src)"></script>
<script src="live.js?v=1774079160" onerror="console.error('Failed to load:', this.src)"></script>
+6 -1
View File
@@ -333,9 +333,14 @@
return;
}
// Favorites always on top
// Claimed ("My Mesh") nodes always on top, then favorites
const myNodes = JSON.parse(localStorage.getItem('meshcore-my-nodes') || '[]');
const myKeys = new Set(myNodes.map(n => n.pubkey));
const favs = getFavorites();
const sorted = [...nodes].sort((a, b) => {
const aMy = myKeys.has(a.public_key) ? 0 : 1;
const bMy = myKeys.has(b.public_key) ? 0 : 1;
if (aMy !== bMy) return aMy - bMy;
const aFav = favs.includes(a.public_key) ? 0 : 1;
const bFav = favs.includes(b.public_key) ? 0 : 1;
return aFav - bFav;