chore: addressed PR comments
All checks were successful
Open PR on Staging / audit_and_check (pull_request) Successful in 32s

This commit is contained in:
daniyal 2024-08-21 12:41:59 +05:00
parent 42d74c656a
commit 4a553c047c
3 changed files with 19 additions and 11 deletions

View File

@ -116,7 +116,7 @@ export class MetadataController extends EventEmitter {
// If cached metadata is found, check its validity // If cached metadata is found, check its validity
if (cachedMetadataEvent) { 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)) { if (isOlderThanOneDay(cachedMetadataEvent.cachedAt)) {
// If older than one week, find the metadata from relays in background // If older than one week, find the metadata from relays in background

View File

@ -96,8 +96,12 @@ export class RelayController {
relayUrls: string[] = [] relayUrls: string[] = []
): Promise<Event[]> => { ): Promise<Event[]> => {
if (!relayUrls.includes(SIGIT_RELAY)) { 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 // connect to all specified relays
@ -216,8 +220,11 @@ export class RelayController {
eventHandler: (event: Event) => void eventHandler: (event: Event) => void
) => { ) => {
if (!relayUrls.includes(SIGIT_RELAY)) { 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 // connect to all specified relays
@ -277,8 +284,11 @@ export class RelayController {
relayUrls: string[] = [] relayUrls: string[] = []
): Promise<string[]> => { ): Promise<string[]> => {
if (!relayUrls.includes(SIGIT_RELAY)) { 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 // connect to all specified relays

View File

@ -130,7 +130,6 @@ const getRelayMap = async (
authors: [npub] authors: [npub]
} }
console.count('getRelayMap')
const event = await relayController const event = await relayController
.fetchEvent(eventFilter, DEFAULT_LOOK_UP_RELAY_LIST) .fetchEvent(eventFilter, DEFAULT_LOOK_UP_RELAY_LIST)
.catch((err) => { .catch((err) => {
@ -155,10 +154,9 @@ const getRelayMap = async (
} }
}) })
Object.keys(relaysMap).forEach((relayUrl) => { Object.keys(relaysMap).forEach((relayUrl) =>
console.log('being called from getRelayMap')
relayController.connectRelay(relayUrl) relayController.connectRelay(relayUrl)
}) )
getRelayInfo(Object.keys(relaysMap)) getRelayInfo(Object.keys(relaysMap))