From 55ce17a962ca02632ed16dd8a63c96b39870735b Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Wed, 19 Aug 2026 18:46:05 +0200 Subject: [PATCH] Account card --- src/App.tsx | 2 +- src/components/view/AccountCard.tsx | 51 +++++++++++++++++++++++++++++ src/components/view/Sidebar.tsx | 32 +++--------------- 3 files changed, 56 insertions(+), 29 deletions(-) create mode 100644 src/components/view/AccountCard.tsx diff --git a/src/App.tsx b/src/App.tsx index 5cab589..3f7d97e 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -29,7 +29,7 @@ export default function App() { return ( -
+
{appRef.current?.accounts && appRef.current.accounts.accounts.length === 0 ? ( diff --git a/src/components/view/AccountCard.tsx b/src/components/view/AccountCard.tsx new file mode 100644 index 0000000..2fefd43 --- /dev/null +++ b/src/components/view/AccountCard.tsx @@ -0,0 +1,51 @@ +import { Card } from "../ui/card"; +import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar"; +import { CopyIcon, Settings2Icon } from "lucide-react"; +import { Button } from "../ui/button"; +import Enclave from "@/app/app"; +import { base58 } from "@scure/base"; +import * as ed from "@noble/ed25519"; + +export default function AccountCard({ + appRef, +}: { + appRef: React.RefObject; +}) { + const account = appRef.current?.getAccount(); + + if (!account) return null; + + return ( +
+ +
+ + + {account.displayName[0]} + +
+ { + navigator.clipboard.writeText( + base58.encode( + ed.getPublicKey(base58.decode(account.privateKey)), + ), + ); + }} + > + {account.displayName} + + + Online +
+
+
+ +
+
+
+ ); +} diff --git a/src/components/view/Sidebar.tsx b/src/components/view/Sidebar.tsx index c42e1a2..a76b0f7 100644 --- a/src/components/view/Sidebar.tsx +++ b/src/components/view/Sidebar.tsx @@ -1,10 +1,8 @@ import Enclave from "@/app/app"; import { Channel, ChannelKind } from "@/app/protocol"; -import { ChevronDown, ChevronUp, HashIcon, Settings2Icon } from "lucide-react"; +import { ChevronDown, ChevronUp, HashIcon } from "lucide-react"; import { useState } from "react"; -import { Card } from "../ui/card"; -import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar"; -import { Button } from "../ui/button"; +import AccountCard from "./AccountCard"; export function ChannelIcon({ kind }: { kind: ChannelKind["kind"] }) { switch (kind) { @@ -23,7 +21,7 @@ export function RenderCategory({ channel }: { channel: Channel }) { return (
setOpen((v) => !v)} > {channel.name} @@ -60,8 +58,6 @@ export default function Sidebar({ }: { appRef: React.RefObject; }) { - const account = appRef.current?.getAccount(); - return (
{appRef.current?.server?.meta && ( @@ -76,27 +72,7 @@ export default function Sidebar({ )} - {account && ( -
- -
- - - {account.displayName[0]} - -
- {account.displayName} - Online -
-
-
- -
-
-
- )} +
); }