Compare commits

...
2 Commits
3 changed files with 45 additions and 8 deletions
+3 -3
View File
@@ -1,5 +1,5 @@
{
"VERSION": "v0.7.52",
"VERSION_NUMBER": "0.7.52",
"BUILD_DATE": "2026-06-26T17:43:40.739Z"
"VERSION": "v0.7.54",
"VERSION_NUMBER": "0.7.54",
"BUILD_DATE": "2026-06-27T01:33:34.109Z"
}
+39 -2
View File
@@ -6443,9 +6443,17 @@ async function handleSetRelayEventLogging(requestId, enabled, port) {
// from followed authors who write to relays the user does not subscribe to.
// For each discovered relay we also report which followed pubkeys it serves,
// by inverting ndk.outboxTracker.data (pubkey -> OutboxItem{writeRelays}).
function shortHexPubkey(hex) {
if (!hex || hex.length < 16) return hex || '-';
return `${hex.slice(0, 8)}${hex.slice(-4)}`;
}
// Cache for discovered relays — rebuilt only when the contact list changes.
// The version suffix forces a rebuild when the handler code changes (e.g.
// adding servingNames).
let discoveredRelaysCache = null;
let discoveredRelaysCacheKey = '';
const DISCOVERED_RELAYS_CACHE_VERSION = 'v2-names';
async function handleGetDiscoveredRelays(requestId, port) {
try {
@@ -6473,7 +6481,7 @@ async function handleGetDiscoveredRelays(requestId, port) {
? Array.from(kind3Events).sort((a, b) => (b.created_at || 0) - (a.created_at || 0))[0]
: null;
const followedPubkeys = latestKind3 ? extractFollowedPubkeysFromKind3(latestKind3) : [];
const cacheKey = `${latestKind3?.id || 'none'}_${latestKind3?.created_at || 0}`;
const cacheKey = `${DISCOVERED_RELAYS_CACHE_VERSION}_${latestKind3?.id || 'none'}_${latestKind3?.created_at || 0}`;
// Rebuild the relay→[pubkeys] mapping from follows' kind 10002 events
// in the Dexie cache if the contact list has changed.
@@ -6527,6 +6535,29 @@ async function handleGetDiscoveredRelays(requestId, port) {
} catch (_) {}
}
// Look up profile names for all serving pubkeys from the Dexie
// profiles table so we can display usernames instead of pubkeys.
const pubkeyToName = new Map();
try {
const adapter = ndk?.cacheAdapter?.adapter;
if (adapter?.db?.profiles) {
const allServingPubkeys = new Set();
for (const servingSet of relayServesPubkeys.values()) {
for (const pk of servingSet) allServingPubkeys.add(pk);
}
// Query profiles table for all serving pubkeys.
for (const pk of allServingPubkeys) {
try {
const row = await adapter.db.profiles.get(pk);
if (row) {
const name = row.displayName || row.name || '';
if (name) pubkeyToName.set(pk, name);
}
} catch (_) {}
}
}
} catch (_) {}
// Build the discovered relays list: relays that are NOT in the
// user's own kind 10002 but ARE in follows' kind 10002.
const relays = [];
@@ -6534,11 +6565,17 @@ async function handleGetDiscoveredRelays(requestId, port) {
if (ownRelays.has(relayUrl)) continue; // skip user's own relays
// Check live connection status from the pool.
const poolRelay = ndk.pool?.relays?.get(relayUrl);
const pubkeys = Array.from(servingSet);
// Map pubkeys to names, falling back to truncated pubkey.
const names = pubkeys.map(pk =>
pubkeyToName.get(pk) || shortHexPubkey(pk)
);
relays.push({
url: relayUrl,
status: poolRelay?.status || 0,
connected: poolRelay ? poolRelay.status >= 5 : false,
servingPubkeys: Array.from(servingSet)
servingPubkeys: pubkeys,
servingNames: names
});
}
// Sort by serving count (most follows first), then by URL.
+3 -3
View File
@@ -1383,9 +1383,9 @@ const versionInfo = await getVersion();
for (const relay of relaysWithFollows) {
const connected = relay.connected ? SVG_CHECKED : SVG_UNCHECKED;
const servingCount = Array.isArray(relay.servingPubkeys) ? relay.servingPubkeys.length : 0;
const followsList = Array.isArray(relay.servingPubkeys)
? relay.servingPubkeys.map(shortNpub).join(', ')
: '-';
const followsList = Array.isArray(relay.servingNames) && relay.servingNames.length > 0
? relay.servingNames.join(', ')
: (Array.isArray(relay.servingPubkeys) ? relay.servingPubkeys.map(shortNpub).join(', ') : '-');
const rowClass = relay.connected ? 'tblRowConnected' : '';
html += `<tr class="${rowClass}">`;