fix: manage pending relay connection requests #159
@ -116,7 +116,7 @@ export class MetadataController extends EventEmitter {
|
||||
|
||||
// If cached metadata is found, check its validity
|
||||
if (cachedMetadataEvent) {
|
||||
// Check if the cached metadata is older than one week
|
||||
// Check if the cached metadata is older than one day
|
||||
if (isOlderThanOneDay(cachedMetadataEvent.cachedAt)) {
|
||||
s marked this conversation as resolved
|
||||
// If older than one week, find the metadata from relays in background
|
||||
|
||||
|
@ -96,8 +96,12 @@ export class RelayController {
|
||||
relayUrls: string[] = []
|
||||
): Promise<Event[]> => {
|
||||
if (!relayUrls.includes(SIGIT_RELAY)) {
|
||||
// Add app relay to relays array if not exists already
|
||||
relayUrls.push(SIGIT_RELAY)
|
||||
/**
|
||||
* NOTE: To avoid side-effects on external relayUrls array passed as argument
|
||||
* re-assigned relayUrls with added sigit relay instead of just appending to same array
|
||||
*/
|
||||
|
||||
relayUrls = [...relayUrls, SIGIT_RELAY] // Add app relay to relays array if not exists already
|
||||
}
|
||||
|
||||
// connect to all specified relays
|
||||
@ -216,8 +220,11 @@ export class RelayController {
|
||||
eventHandler: (event: Event) => void
|
||||
) => {
|
||||
if (!relayUrls.includes(SIGIT_RELAY)) {
|
||||
// Add app relay to relays array if not exists already
|
||||
relayUrls.push(SIGIT_RELAY)
|
||||
/**
|
||||
* NOTE: To avoid side-effects on external relayUrls array passed as argument
|
||||
* re-assigned relayUrls with added sigit relay instead of just appending to same array
|
||||
*/
|
||||
relayUrls = [...relayUrls, SIGIT_RELAY] // Add app relay to relays array if not exists already
|
||||
}
|
||||
|
||||
// connect to all specified relays
|
||||
@ -277,8 +284,11 @@ export class RelayController {
|
||||
relayUrls: string[] = []
|
||||
): Promise<string[]> => {
|
||||
if (!relayUrls.includes(SIGIT_RELAY)) {
|
||||
// Add app relay to relays array if not exists already
|
||||
relayUrls.push(SIGIT_RELAY)
|
||||
/**
|
||||
* NOTE: To avoid side-effects on external relayUrls array passed as argument
|
||||
* re-assigned relayUrls with added sigit relay instead of just appending to same array
|
||||
*/
|
||||
relayUrls = [...relayUrls, SIGIT_RELAY] // Add app relay to relays array if not exists already
|
||||
}
|
||||
|
||||
// connect to all specified relays
|
||||
|
@ -130,7 +130,6 @@ const getRelayMap = async (
|
||||
authors: [npub]
|
||||
}
|
||||
|
||||
console.count('getRelayMap')
|
||||
const event = await relayController
|
||||
.fetchEvent(eventFilter, DEFAULT_LOOK_UP_RELAY_LIST)
|
||||
.catch((err) => {
|
||||
@ -155,10 +154,9 @@ const getRelayMap = async (
|
||||
}
|
||||
})
|
||||
|
||||
Object.keys(relaysMap).forEach((relayUrl) => {
|
||||
console.log('being called from getRelayMap')
|
||||
Object.keys(relaysMap).forEach((relayUrl) =>
|
||||
relayController.connectRelay(relayUrl)
|
||||
})
|
||||
)
|
||||
|
||||
getRelayInfo(Object.keys(relaysMap))
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user
There is a discrepancy between the function name and the comments around it. Should it be older than one week or one day?
fixed, Updated comment