diff --git a/js/nostr-broadcast.js b/js/nostr-broadcast.js index 9059d15..825b6a2 100644 --- a/js/nostr-broadcast.js +++ b/js/nostr-broadcast.js @@ -34,10 +34,9 @@ const fetchAndBroadcast = async () => { // get all events from relays const filters =[{ authors: [pubkey] }, { "#p": [pubkey] }] - const data = await getEvents(filters, pubkey) - - const kind3 = data.filter((it) => it.kind == 3 && it.pubkey === pubkey).sort((a, b) => b.created_at - a.created_at)[0] - const myRelaySet = JSON.parse(kind3.content) + const data = (await getEvents(filters, pubkey)).sort((a, b) => b.created_at - a.created_at) + const latestKind3 = data.filter((it) => it.kind == 3 && it.pubkey === pubkey)[0] + const myRelaySet = JSON.parse(latestKind3.content) relays = Object.keys(myRelaySet).filter(url => myRelaySet[url].write).map(url => url) $('#checking-relays-header-box').css('display', 'none') diff --git a/js/nostr-utils.js b/js/nostr-utils.js index a393fef..5054528 100644 --- a/js/nostr-utils.js +++ b/js/nostr-utils.js @@ -98,7 +98,7 @@ function hexToBytes(hex) { myTimeout = setTimeout(() => { ws.close() reject('timeout') - }, 5_000) + }, 10_000) const { id } = data