feat: add create account flow

This commit is contained in:
2024-03-28 15:12:43 +07:00
parent d3fa59d2b1
commit cbbf5eaf50
18 changed files with 714 additions and 152 deletions

View File

@@ -6,6 +6,7 @@ import type {
EventWithReplies,
Keys,
Metadata,
Settings,
} from "@lume/types";
import { invoke } from "@tauri-apps/api/core";
import { open } from "@tauri-apps/plugin-dialog";
@@ -338,6 +339,25 @@ export class Ark {
}
}
public async create_profile(profile: Metadata) {
try {
const event: string = await invoke("create_profile", {
name: profile.name || "",
display_name: profile.display_name || "",
displayName: profile.display_name || "",
about: profile.about || "",
picture: profile.picture || "",
banner: profile.banner || "",
nip05: profile.nip05 || "",
lud16: profile.lud16 || "",
website: profile.website || "",
});
return event;
} catch (e) {
throw new Error(String(e));
}
}
public async get_contact_list() {
try {
const cmd: string[] = await invoke("get_contact_list");
@@ -499,6 +519,30 @@ export class Ark {
}
}
public async get_settings(id: string) {
try {
const cmd: string = await invoke("get_settings", { id });
if (!cmd) return null;
if (!cmd.length) return null;
const settings: Settings = JSON.parse(cmd);
return settings;
} catch (e) {
throw new Error(e);
}
}
public async set_settings(settings: Settings) {
try {
const cmd: string = await invoke("set_settings", {
content: JSON.stringify(settings),
});
return cmd;
} catch (e) {
throw new Error(e);
}
}
public open_thread(id: string) {
return new WebviewWindow(`event-${id}`, {
title: "Thread",