From dc7f4d2f6116c187bb10682834428af11c90f954 Mon Sep 17 00:00:00 2001 From: Klesti Selimaj Date: Fri, 21 Aug 2026 13:14:52 +0200 Subject: [PATCH] Current user author --- src/components/page/channel/TextChannel.tsx | 30 ++++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/components/page/channel/TextChannel.tsx b/src/components/page/channel/TextChannel.tsx index 67a2cc1..54c2e93 100644 --- a/src/components/page/channel/TextChannel.tsx +++ b/src/components/page/channel/TextChannel.tsx @@ -1,10 +1,12 @@ import Enclave from "@/app/app"; import { ChannelPageProps } from "@/components/page/PageView"; -import { Avatar, AvatarFallback } from "@/components/ui/avatar"; +import { Avatar, AvatarFallback, AvatarImage } from "@/components/ui/avatar"; import { Button } from "@/components/ui/button"; import { Input } from "@/components/ui/input"; -import { StoredMessage } from "@/lib/types"; +import { ClientMeta, StoredMessage } from "@/lib/types"; +import { base58 } from "@scure/base"; import { useEffect, useRef, useState } from "react"; +import * as ed from "@noble/ed25519"; export default function TextChannel({ appRef, @@ -90,6 +92,7 @@ export default function TextChannel({ } export function TextMessage({ + appRef, message, }: { appRef: React.RefObject | null>; @@ -100,18 +103,37 @@ export function TextMessage({ minute: "2-digit", }); + const [author, setAuthor] = useState(null); + + useEffect(() => { + const currentAccount = appRef.current?.getAccount(); + + if (currentAccount) { + const pubKey = base58.encode( + ed.getPublicKey(base58.decode(currentAccount.privateKey)), + ); + + if (pubKey === message.author) { + setAuthor(currentAccount.meta); + } + } + }, []); + return (
+ + - {message.author.slice(0, 2).toUpperCase()} + {author?.displayName.slice(0, 1).toUpperCase() || + message.author.slice(0, 2).toUpperCase()}
- {message.author.slice(0, 8)} + {author?.displayName || message.author.slice(0, 8)} {time}