feat(ark): add user component

This commit is contained in:
2024-01-13 08:21:49 +07:00
parent 0487b8a801
commit 1822eac488
18 changed files with 324 additions and 317 deletions

View File

@@ -198,13 +198,13 @@ export class Ark {
}
}
public async createContact({ pubkey }: { pubkey: string }) {
public async createContact(pubkey: string) {
const user = this.ndk.getUser({ pubkey: this.account.pubkey });
const contacts = await user.follows();
return await user.follow(new NDKUser({ pubkey: pubkey }), contacts);
}
public async deleteContact({ pubkey }: { pubkey: string }) {
public async deleteContact(pubkey: string) {
const user = this.ndk.getUser({ pubkey: this.account.pubkey });
const contacts = await user.follows();
contacts.delete(new NDKUser({ pubkey: pubkey }));
@@ -549,17 +549,12 @@ export class Ark {
signal,
});
if (!res.ok) {
console.log(res);
throw new Error(`Failed to fetch NIP-05 service: ${nip05}`);
}
if (!res.ok) throw new Error(`Failed to fetch NIP-05 service: ${nip05}`);
const data: NIP05 = await res.json();
if (!data.names) return false;
if (data.names[localPath.toLowerCase()] === pubkey) return true;
if (data.names[localPath] === pubkey) return true;
return false;
}