feat: add login dialog

This commit is contained in:
2024-03-06 09:42:44 +07:00
parent 86183d799a
commit 8eaf47f6d2
17 changed files with 336 additions and 167 deletions

View File

@@ -31,7 +31,6 @@ export class Ark {
this.accounts = accounts;
return accounts;
} catch (e) {
console.error(e);
return [];
}
}
@@ -45,19 +44,18 @@ export class Ark {
return cmd;
} catch (e) {
console.error(e);
return false;
throw new Error(String(e));
}
}
public async create_guest_account() {
try {
const keys = await this.create_keys();
await this.save_account(keys);
await this.save_account(keys.nsec, "");
return keys.npub;
} catch (e) {
console.error(e);
throw new Error(String(e));
}
}
@@ -70,17 +68,20 @@ export class Ark {
}
}
public async save_account(keys: Keys) {
public async save_account(nsec: string, password: string = "") {
try {
const cmd: boolean = await invoke("save_key", { nsec: keys.nsec });
const cmd: boolean = await invoke("save_key", {
nsec,
password,
});
if (cmd) {
await invoke("update_signer", { nsec: keys.nsec });
await invoke("update_signer", { nsec });
}
return cmd;
} catch (e) {
console.error(String(e));
throw new Error(String(e));
}
}
@@ -92,7 +93,7 @@ export class Ark {
});
return cmd;
} catch (e) {
console.error(String(e));
throw new Error(String(e));
}
}
@@ -106,7 +107,7 @@ export class Ark {
const event: Event = JSON.parse(cmd);
return event;
} catch (e) {
return null;
throw new Error(String(e));
}
}
@@ -210,8 +211,7 @@ export class Ark {
return cmd;
} catch (e) {
console.error(String(e));
return false;
throw new Error(String(e));
}
}
@@ -220,7 +220,7 @@ export class Ark {
const cmd: string = await invoke("reply_to", { content, tags });
return cmd;
} catch (e) {
console.error(String(e));
throw new Error(String(e));
}
}
@@ -229,7 +229,7 @@ export class Ark {
const cmd: string = await invoke("repost", { id, pubkey: author });
return cmd;
} catch (e) {
console.error(String(e));
throw new Error(String(e));
}
}
@@ -238,7 +238,7 @@ export class Ark {
const cmd: string = await invoke("upvote", { id, pubkey: author });
return cmd;
} catch (e) {
console.error(String(e));
throw new Error(String(e));
}
}
@@ -247,7 +247,7 @@ export class Ark {
const cmd: string = await invoke("downvote", { id, pubkey: author });
return cmd;
} catch (e) {
console.error(String(e));
throw new Error(String(e));
}
}
@@ -366,8 +366,7 @@ export class Ark {
const cmd: string = await invoke("follow", { id, alias });
return cmd;
} catch (e) {
console.error(e);
return false;
throw new Error(String(e));
}
}
@@ -376,8 +375,7 @@ export class Ark {
const cmd: string = await invoke("unfollow", { id });
return cmd;
} catch (e) {
console.error(e);
return false;
throw new Error(String(e));
}
}
@@ -389,7 +387,7 @@ export class Ark {
});
return cmd;
} catch (e) {
console.error(String(e));
throw new Error(String(e));
}
}

View File

@@ -1,18 +1,13 @@
export function ArrowRightIcon(props: JSX.IntrinsicElements['svg']) {
export function ArrowRightIcon(props: JSX.IntrinsicElements["svg"]) {
return (
<svg
{...props}
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
width="24"
height="24"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
>
<path d="M15.17 6a30.23 30.23 0 0 1 5.62 5.406c.14.174.21.384.21.594m-5.83 6a30.232 30.232 0 0 0 5.62-5.406A.949.949 0 0 0 21 12m0 0H3" />
<svg width="24" height="24" fill="none" viewBox="0 0 24 24" {...props}>
<path
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
d="m14 6 6 6-6 6m5-6H4"
/>
</svg>
);
}

View File

@@ -1,18 +1,12 @@
export function CancelIcon(props: JSX.IntrinsicElements['svg']) {
export function CancelIcon(props: JSX.IntrinsicElements["svg"]) {
return (
<svg
{...props}
xmlns="http://www.w3.org/2000/svg"
viewBox="0 0 24 24"
width="24"
height="24"
fill="none"
stroke="currentColor"
strokeLinecap="round"
strokeLinejoin="round"
strokeWidth="2"
>
<path d="m6 18 6-6m0 0 6-6m-6 6L6 6m6 6 6 6" />
<svg width="24" height="24" fill="none" viewBox="0 0 24 24" {...props}>
<path
stroke="currentColor"
stroke-linecap="round"
stroke-width="2"
d="m5 5 14 14m0-14L5 19"
/>
</svg>
);
}

View File

@@ -7,14 +7,16 @@ export function SettingsIcon(
<svg width="24" height="24" fill="none" viewBox="0 0 24 24" {...props}>
<path
stroke="currentColor"
stroke-linejoin="round"
stroke-width="2"
d="m7.99 5.398-.685-.158A1.722 1.722 0 0 0 5.24 7.305l.158.684a1.946 1.946 0 0 1-.817 2.057l-.832.555a1.682 1.682 0 0 0 0 2.798l.832.555c.673.449.999 1.268.817 2.057l-.158.684a1.722 1.722 0 0 0 2.065 2.065l.684-.158a1.946 1.946 0 0 1 2.057.817l.555.832a1.682 1.682 0 0 0 2.798 0l.555-.832a1.946 1.946 0 0 1 2.057-.817l.684.158a1.722 1.722 0 0 0 2.065-2.065l-.158-.684a1.946 1.946 0 0 1 .817-2.057l.832-.555a1.682 1.682 0 0 0 0-2.798l-.832-.555a1.946 1.946 0 0 1-.817-2.057l.158-.684a1.722 1.722 0 0 0-2.065-2.065l-.684.158a1.946 1.946 0 0 1-2.057-.817l-.555-.832a1.682 1.682 0 0 0-2.798 0l-.555.832a1.946 1.946 0 0 1-2.057.817Z"
strokeLinecap="square"
strokeLinejoin="round"
strokeWidth="2"
d="M11.02 3.552a2 2 0 0 1 1.96 0l6 3.374A2 2 0 0 1 20 8.67v6.66a2 2 0 0 1-1.02 1.743l-6 3.375a2 2 0 0 1-1.96 0l-6-3.374A2 2 0 0 1 4 15.33V8.67a2 2 0 0 1 1.02-1.744l6-3.374Z"
/>
<path
stroke="currentColor"
stroke-linejoin="round"
stroke-width="2"
strokeLinecap="square"
strokeLinejoin="round"
strokeWidth="2"
d="M15 12a3 3 0 1 1-6 0 3 3 0 0 1 6 0Z"
/>
</svg>