Complete the following list import functionality

This commit is contained in:
SondreB 2023-01-01 05:12:03 +01:00
parent 755a2fa76a
commit 431f59887e
No known key found for this signature in database
GPG Key ID: D6CC44C75005FDBF
6 changed files with 27 additions and 15 deletions

View File

@ -36,21 +36,13 @@
<mat-icon>content_copy</mat-icon>
<span>Public Keys (hex)</span>
</button>
<!-- <button mat-menu-item (click)="copyProfile()">
<mat-icon>content_copy</mat-icon>
<span>Profiles</span>
</button> -->
</mat-menu>
<!-- <button *ngIf="!fab" class="action-button" mat-icon-button [matMenuTriggerFor]="menu">
<mat-icon class="action-button-icon">more_vert</mat-icon>
</button> -->
</div>
</div>
<p class="circle-actions">
<button mat-stroked-button (click)="importFollowList()">Import Follow List</button>
<button mat-stroked-button (click)="publishFollowList()">Publish Follow List</button>
<button mat-stroked-button (click)="importFollowList()">Import Following List</button>
<!-- <button mat-stroked-button (click)="publishFollowList()">Publish Follow List</button> -->
</p>
<p class="dimmed">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.</p>

View File

@ -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);

View File

@ -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('/');
}

View File

@ -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]);

View File

@ -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) {

View File

@ -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');