From 431f59887ed89218087c7ca145bc493c2e070a17 Mon Sep 17 00:00:00 2001 From: SondreB Date: Sun, 1 Jan 2023 05:12:03 +0100 Subject: [PATCH] Complete the following list import functionality --- src/app/circles/circles.component.html | 12 ++---------- src/app/circles/circles.component.ts | 2 +- src/app/connect/connect.component.ts | 2 +- src/app/people/people.component.ts | 4 +--- src/app/services/relay.service.ts | 14 ++++++++++++++ src/app/services/utilities.service.ts | 8 ++++++++ 6 files changed, 27 insertions(+), 15 deletions(-) diff --git a/src/app/circles/circles.component.html b/src/app/circles/circles.component.html index edc875e..58e8906 100644 --- a/src/app/circles/circles.component.html +++ b/src/app/circles/circles.component.html @@ -36,21 +36,13 @@ content_copy Public Keys (hex) - - -

- - + +

Circles is how you organize people you follow. Different circles can have different rules applied and circles is an important way to make the experience more enjoyable.

diff --git a/src/app/circles/circles.component.ts b/src/app/circles/circles.component.ts index 8712eb6..65ebd0a 100644 --- a/src/app/circles/circles.component.ts +++ b/src/app/circles/circles.component.ts @@ -83,7 +83,7 @@ export class CirclesComponent { verticalPosition: 'bottom', }); - let pubkey = result.pubkey; + let pubkey = this.utilities.ensureHexIdentifier(result.pubkey); console.log('GET FOLLOWING LIST FOR:', pubkey); diff --git a/src/app/connect/connect.component.ts b/src/app/connect/connect.component.ts index 5e81f1f..ba440e2 100644 --- a/src/app/connect/connect.component.ts +++ b/src/app/connect/connect.component.ts @@ -36,7 +36,7 @@ export class ConnectComponent { await this.relayService.appendRelays(relays); // Initiate connections against registered relays. - this.relayService.connect(); + // this.relayService.connect(); this.router.navigateByUrl('/'); } diff --git a/src/app/people/people.component.ts b/src/app/people/people.component.ts index c371939..a57bc8f 100644 --- a/src/app/people/people.component.ts +++ b/src/app/people/people.component.ts @@ -125,9 +125,7 @@ export class PeopleComponent { return; } - if (pubkey.startsWith('npub')) { - pubkey = this.utilities.arrayToHex(this.utilities.convertFromBech32(pubkey)); - } + pubkey = this.utilities.ensureHexIdentifier(pubkey); await this.profileService.follow(pubkey); await this.feedService.downloadRecent([pubkey]); diff --git a/src/app/services/relay.service.ts b/src/app/services/relay.service.ts index a794f9e..b0bacd2 100644 --- a/src/app/services/relay.service.ts +++ b/src/app/services/relay.service.ts @@ -598,6 +598,20 @@ export class RelayService { } async initialize() { + if (this.relays.length === 0) { + let relays; + + try { + const gt = globalThis as any; + relays = await gt.nostr.getRelays(); + } catch (err) { + relays = this.defaultRelays; + } + + // First append whatever the extension give us of relays. + await this.appendRelays(relays); + } + // Whenever the profile service needs to get a profile from the network, this event is triggered. // this.profileService.profileRequested$.subscribe(async (pubkey) => { // if (!pubkey) { diff --git a/src/app/services/utilities.service.ts b/src/app/services/utilities.service.ts index 62038d5..33033e2 100644 --- a/src/app/services/utilities.service.ts +++ b/src/app/services/utilities.service.ts @@ -16,6 +16,14 @@ export class Utilities { return converted; } + ensureHexIdentifier(pubkey: string) { + if (pubkey.startsWith('npub')) { + pubkey = this.arrayToHex(this.convertFromBech32(pubkey)); + } + + return pubkey; + } + getHexIdentifier(pubkey: string) { const key = this.hexToArray(pubkey); const converted = this.convertToBech32(key, 'npub');