From 2355da02d2c760f94509bcb4e375e75b61a2ce9f Mon Sep 17 00:00:00 2001 From: Eugene Date: Wed, 7 Aug 2024 16:04:56 +0300 Subject: [PATCH] fix: amends RelayMap to return a default sigit relay when no other relays are found --- src/controllers/NostrController.ts | 5 +++-- src/pages/settings/relays/index.tsx | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/controllers/NostrController.ts b/src/controllers/NostrController.ts index 13787e5..fa558de 100644 --- a/src/controllers/NostrController.ts +++ b/src/controllers/NostrController.ts @@ -44,6 +44,7 @@ import { getNsecBunkerDelegatedKey, verifySignedEvent } from '../utils' +import { getDefaultRelayMap } from '../utils/relays.ts' export class NostrController extends EventEmitter { private static instance: NostrController @@ -650,7 +651,7 @@ export class NostrController extends EventEmitter { */ getRelayMap = async ( npub: string - ): Promise<{ map: RelayMap; mapUpdated: number }> => { + ): Promise<{ map: RelayMap; mapUpdated?: number }> => { const mostPopularRelays = await this.getMostPopularRelays() const pool = new SimplePool() @@ -691,7 +692,7 @@ export class NostrController extends EventEmitter { return Promise.resolve({ map: relaysMap, mapUpdated: event.created_at }) } else { - return Promise.reject('User relays were not found.') + return Promise.resolve({ map: getDefaultRelayMap() }) } } diff --git a/src/pages/settings/relays/index.tsx b/src/pages/settings/relays/index.tsx index 1894fc4..b06908a 100644 --- a/src/pages/settings/relays/index.tsx +++ b/src/pages/settings/relays/index.tsx @@ -91,7 +91,7 @@ export const RelaysPage = () => { if (isMounted) { if ( !relaysState?.mapUpdated || - newRelayMap.mapUpdated > relaysState?.mapUpdated + newRelayMap?.mapUpdated !== undefined && (newRelayMap?.mapUpdated > relaysState?.mapUpdated) ) { if ( !relaysState?.map ||