diff --git a/apps/desktop2/package.json b/apps/desktop2/package.json
index 256e1f49..763359f7 100644
--- a/apps/desktop2/package.json
+++ b/apps/desktop2/package.json
@@ -15,6 +15,7 @@
"@lume/utils": "workspace:^",
"@radix-ui/react-checkbox": "^1.0.4",
"@radix-ui/react-collapsible": "^1.0.3",
+ "@radix-ui/react-dialog": "^1.0.5",
"@radix-ui/react-dropdown-menu": "^2.0.6",
"@radix-ui/react-popover": "^1.0.7",
"@tanstack/query-sync-storage-persister": "^5.24.1",
diff --git a/apps/desktop2/src/components/accounts.tsx b/apps/desktop2/src/components/accounts.tsx
index dbf134fd..de125ef6 100644
--- a/apps/desktop2/src/components/accounts.tsx
+++ b/apps/desktop2/src/components/accounts.tsx
@@ -4,9 +4,9 @@ import { User } from "@lume/ui";
import { useNavigate, useParams, useSearch } from "@tanstack/react-router";
import { useEffect, useState } from "react";
import * as Popover from "@radix-ui/react-popover";
-import { Link } from "@tanstack/react-router";
-import { useTranslation } from "react-i18next";
import * as DropdownMenu from "@radix-ui/react-dropdown-menu";
+import { BackupDialog } from "./backup";
+import { LoginDialog } from "./login";
export function Accounts() {
const ark = useArk();
@@ -63,7 +63,6 @@ function Active({ pubkey }: { pubkey: string }) {
const [open, setOpen] = useState(true);
// @ts-ignore, magic !!!
const { guest } = useSearch({ strict: false });
- const { t } = useTranslation();
if (guest) {
return (
@@ -84,25 +83,17 @@ function Active({ pubkey }: { pubkey: string }) {
side="bottom"
>
-
You're using guest account
+
+ You're using random account
+
You can continue by claim and backup this account, or you can
- import your own account key.
+ import your own account.
-
- Claim & Backup
-
-
- {t("welcome.login")}
-
+
+
diff --git a/apps/desktop2/src/components/backup.tsx b/apps/desktop2/src/components/backup.tsx
new file mode 100644
index 00000000..c124e665
--- /dev/null
+++ b/apps/desktop2/src/components/backup.tsx
@@ -0,0 +1,85 @@
+import { CancelIcon } from "@lume/icons";
+import * as Dialog from "@radix-ui/react-dialog";
+import { useState } from "react";
+
+export function BackupDialog() {
+ const [key, setKey] = useState("");
+ const [passphase, setPassphase] = useState("");
+
+ const encryptKey = async () => {
+ console.log("****");
+ };
+
+ return (
+
+
+
+
+
+
+
+
+
+
+ Esc
+
+
+
+
+
+ This is your account key
+
+
+ It's use for login to Lume or other Nostr clients. You will lost
+ access to your account if you lose this key.
+
+
+
+
+
+
+
+
+
+
+
setPassphase(e.target.value)}
+ className="h-11 w-full resize-none rounded-lg border-transparent bg-neutral-100 placeholder:text-neutral-600 focus:border-blue-500 focus:ring focus:ring-blue-100 dark:bg-neutral-900 dark:focus:ring-blue-900"
+ />
+ {passphase.length ? (
+
+
+
+ ) : null}
+
+
+
+
+
+
+
+ );
+}
diff --git a/apps/desktop2/src/components/login.tsx b/apps/desktop2/src/components/login.tsx
new file mode 100644
index 00000000..0d8cf6f2
--- /dev/null
+++ b/apps/desktop2/src/components/login.tsx
@@ -0,0 +1,120 @@
+import { useArk } from "@lume/ark";
+import { ArrowRightIcon, CancelIcon } from "@lume/icons";
+import * as Dialog from "@radix-ui/react-dialog";
+import { useNavigate } from "@tanstack/react-router";
+import { useState } from "react";
+import { toast } from "sonner";
+
+export function LoginDialog() {
+ const ark = useArk();
+ const navigate = useNavigate();
+
+ const [nsec, setNsec] = useState("");
+ const [passphase, setPassphase] = useState("");
+ const [loading, setLoading] = useState(false);
+
+ const login = async () => {
+ try {
+ setLoading(true);
+
+ const save = await ark.save_account(nsec, passphase);
+
+ if (save) {
+ navigate({ to: "/", search: { guest: false } });
+ }
+ } catch (e) {
+ setLoading(false);
+ toast.error(String(e));
+ }
+ };
+
+ return (
+
+
+
+
+
+
+
+
+
+
+ Esc
+
+
+
+
+
Add new account with
+
+
+
+
+
+
+
+
+
+
+
+
+ );
+}
diff --git a/apps/desktop2/src/routes/$account.tsx b/apps/desktop2/src/routes/$account.tsx
index 546d0a3d..bf3defaf 100644
--- a/apps/desktop2/src/routes/$account.tsx
+++ b/apps/desktop2/src/routes/$account.tsx
@@ -5,6 +5,7 @@ import {
HomeFilledIcon,
HomeIcon,
HorizontalDotsIcon,
+ SettingsIcon,
SpaceFilledIcon,
SpaceIcon,
} from "@lume/icons";
@@ -43,6 +44,12 @@ function App() {
New post
+
diff --git a/apps/desktop2/src/routes/backup.lazy.tsx b/apps/desktop2/src/routes/backup.lazy.tsx
deleted file mode 100644
index 31cdd902..00000000
--- a/apps/desktop2/src/routes/backup.lazy.tsx
+++ /dev/null
@@ -1,20 +0,0 @@
-import { createLazyFileRoute } from "@tanstack/react-router";
-import { useTranslation } from "react-i18next";
-
-export const Route = createLazyFileRoute("/backup")({
- component: Screen,
-});
-
-function Screen() {
- const { t } = useTranslation();
-
- return (
-
-
-
-
{t("backup.title")}
-
-
-
- );
-}
diff --git a/apps/desktop2/src/routes/index.tsx b/apps/desktop2/src/routes/index.tsx
index 760b708a..98d6fa86 100644
--- a/apps/desktop2/src/routes/index.tsx
+++ b/apps/desktop2/src/routes/index.tsx
@@ -6,7 +6,7 @@ import { createFileRoute, redirect, useNavigate } from "@tanstack/react-router";
import { useState } from "react";
export const Route = createFileRoute("/")({
- beforeLoad: async ({ location, context }) => {
+ beforeLoad: async ({ context }) => {
const ark = context.ark;
const accounts = await ark.get_all_accounts();
diff --git a/apps/desktop2/src/routes/login.tsx b/apps/desktop2/src/routes/login.tsx
deleted file mode 100644
index 4bc1d153..00000000
--- a/apps/desktop2/src/routes/login.tsx
+++ /dev/null
@@ -1,14 +0,0 @@
-import { Outlet, createFileRoute } from "@tanstack/react-router";
-
-export const Route = createFileRoute("/login")({
- component: Screen,
-});
-
-function Screen() {
- return (
-
-
Login
-
-
- );
-}
diff --git a/packages/ark/src/ark.ts b/packages/ark/src/ark.ts
index af64ad67..400d0c9a 100644
--- a/packages/ark/src/ark.ts
+++ b/packages/ark/src/ark.ts
@@ -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));
}
}
diff --git a/packages/icons/src/arrowRight.tsx b/packages/icons/src/arrowRight.tsx
index 33ebdc07..99ffaa37 100644
--- a/packages/icons/src/arrowRight.tsx
+++ b/packages/icons/src/arrowRight.tsx
@@ -1,18 +1,13 @@
-export function ArrowRightIcon(props: JSX.IntrinsicElements['svg']) {
+export function ArrowRightIcon(props: JSX.IntrinsicElements["svg"]) {
return (
-