|
|
|
|
@ -4,7 +4,7 @@ import { ndkInstance } from '$lib/ndk';
@@ -4,7 +4,7 @@ import { ndkInstance } from '$lib/ndk';
|
|
|
|
|
import { npubCache } from './npubCache'; |
|
|
|
|
import NDK, { NDKEvent, NDKRelaySet, NDKUser } from "@nostr-dev-kit/ndk"; |
|
|
|
|
import type { NDKFilter, NDKKind } from "@nostr-dev-kit/ndk"; |
|
|
|
|
import { standardRelays, bootstrapRelays } from "$lib/consts"; |
|
|
|
|
import { standardRelays, fallbackRelays } from "$lib/consts"; |
|
|
|
|
|
|
|
|
|
const badgeCheckSvg = '<svg class="w-6 h-6 text-gray-800 dark:text-white" aria-hidden="true" xmlns="http://www.w3.org/2000/svg" width="24" height="24" fill="currentColor" viewBox="0 0 24 24"><path fill-rule="evenodd" d="M12 2c-.791 0-1.55.314-2.11.874l-.893.893a.985.985 0 0 1-.696.288H7.04A2.984 2.984 0 0 0 4.055 7.04v1.262a.986.986 0 0 1-.288.696l-.893.893a2.984 2.984 0 0 0 0 4.22l.893.893a.985.985 0 0 1 .288.696v1.262a2.984 2.984 0 0 0 2.984 2.984h1.262c.261 0 .512.104.696.288l.893.893a2.984 2.984 0 0 0 4.22 0l.893-.893a.985.985 0 0 1 .696-.288h1.262a2.984 2.984 0 0 0 2.984-2.984V15.7c0-.261.104-.512.288-.696l.893-.893a2.984 2.984 0 0 0 0-4.22l-.893-.893a.985.985 0 0 1-.288-.696V7.04a2.984 2.984 0 0 0-2.984-2.984h-1.262a.985.985 0 0 1-.696-.288l-.893-.893A2.984 2.984 0 0 0 12 2Zm3.683 7.73a1 1 0 1 0-1.414-1.413l-4.253 4.253-1.277-1.277a1 1 0 0 0-1.415 1.414l1.985 1.984a1 1 0 0 0 1.414 0l4.96-4.96Z" clip-rule="evenodd"/></svg>' |
|
|
|
|
|
|
|
|
|
@ -306,7 +306,7 @@ export async function fetchEventWithFallback(
@@ -306,7 +306,7 @@ export async function fetchEventWithFallback(
|
|
|
|
|
const relaySets = [ |
|
|
|
|
NDKRelaySet.fromRelayUrls(standardRelays, ndk), // 1. Standard relays
|
|
|
|
|
NDKRelaySet.fromRelayUrls(userRelays, ndk), // 2. User relays (if logged in)
|
|
|
|
|
NDKRelaySet.fromRelayUrls(bootstrapRelays, ndk) // 3. Bootstrap relays (last resort)
|
|
|
|
|
NDKRelaySet.fromRelayUrls(fallbackRelays, ndk) // 3. fallback relays (last resort)
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
@ -331,7 +331,7 @@ export async function fetchEventWithFallback(
@@ -331,7 +331,7 @@ export async function fetchEventWithFallback(
|
|
|
|
|
for (const [index, relaySet] of relaySets.entries()) { |
|
|
|
|
const setName = index === 0 ? 'standard relays' :
|
|
|
|
|
index === 1 ? 'user relays' :
|
|
|
|
|
'bootstrap relays'; |
|
|
|
|
'fallback relays'; |
|
|
|
|
|
|
|
|
|
found = await tryFetchFromRelaySet(relaySet, setName); |
|
|
|
|
if (found) break; |
|
|
|
|
@ -342,7 +342,7 @@ export async function fetchEventWithFallback(
@@ -342,7 +342,7 @@ export async function fetchEventWithFallback(
|
|
|
|
|
const relayUrls = relaySets.map((set, i) => { |
|
|
|
|
const setName = i === 0 ? 'standard relays' :
|
|
|
|
|
i === 1 ? 'user relays' :
|
|
|
|
|
'bootstrap relays'; |
|
|
|
|
'fallback relays'; |
|
|
|
|
const urls = Array.from(set.relays).map(r => r.url); |
|
|
|
|
return urls.length > 0 ? `${setName} (${urls.join(', ')})` : null; |
|
|
|
|
}).filter(Boolean).join(', then '); |
|
|
|
|
|