feat: polish
This commit is contained in:
@@ -552,9 +552,11 @@ export class Ark {
|
||||
if (!res.ok) throw new Error(`Failed to fetch NIP-05 service: ${nip05}`);
|
||||
|
||||
const data: NIP05 = await res.json();
|
||||
|
||||
if (!data.names) return false;
|
||||
if (data.names[localPath.toLowerCase()] === pubkey) return true;
|
||||
if (data.names[localPath] === pubkey) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -12,17 +12,16 @@ export function ThreadNote({ eventId }: { eventId: string }) {
|
||||
return (
|
||||
<Note.Provider event={data}>
|
||||
<Note.Root>
|
||||
<div className="flex items-center justify-between px-3 h-14">
|
||||
<Note.User className="flex-1 pr-1" />
|
||||
<div className="flex items-center justify-between px-3 h-16">
|
||||
<User.Provider pubkey={data.pubkey}>
|
||||
<User.Root className="flex h-16 items-center gap-3 px-3 flex-1">
|
||||
<User.Root className="flex h-16 items-center gap-3 flex-1">
|
||||
<User.Avatar className="size-10 shrink-0 rounded-lg object-cover ring-1 ring-neutral-200/50 dark:ring-neutral-800/50" />
|
||||
<div className="flex flex-1 flex-col">
|
||||
<User.Name className="font-semibold text-neutral-900 dark:text-neutral-100" />
|
||||
<div className="inline-flex items-center gap-2 text-sm text-neutral-600 dark:text-neutral-400">
|
||||
<User.Time time={data.created_at} />
|
||||
<span>·</span>
|
||||
<User.NIP05 />
|
||||
<User.NIP05 pubkey={data.pubkey} />
|
||||
</div>
|
||||
</div>
|
||||
</User.Root>
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { cn } from "@lume/utils";
|
||||
import * as Avatar from "@radix-ui/react-avatar";
|
||||
import { minidenticon } from "minidenticons";
|
||||
import { nanoid } from "nanoid";
|
||||
import { useMemo } from "react";
|
||||
import { useUserContext } from "./provider";
|
||||
|
||||
@@ -9,7 +10,7 @@ export function UserAvatar({ className }: { className?: string }) {
|
||||
const fallbackAvatar = useMemo(
|
||||
() =>
|
||||
`data:image/svg+xml;utf8,${encodeURIComponent(
|
||||
minidenticon(user?.pubkey, 90, 50),
|
||||
minidenticon(user?.pubkey || nanoid(), 90, 50),
|
||||
)}`,
|
||||
[user],
|
||||
);
|
||||
|
||||
@@ -4,19 +4,25 @@ import { useQuery } from "@tanstack/react-query";
|
||||
import { useArk } from "../../hooks/useArk";
|
||||
import { useUserContext } from "./provider";
|
||||
|
||||
export function UserNip05({ className }: { className?: string }) {
|
||||
export function UserNip05({
|
||||
pubkey,
|
||||
className,
|
||||
}: { pubkey: string; className?: string }) {
|
||||
const ark = useArk();
|
||||
const user = useUserContext();
|
||||
|
||||
const { isLoading, data: verified } = useQuery({
|
||||
queryKey: ["nip05", user?.nip05],
|
||||
queryFn: async ({ signal }: { signal: AbortSignal }) => {
|
||||
if (!user) return false;
|
||||
if (!user.nip05) return false;
|
||||
return ark.validateNIP05({
|
||||
pubkey: user?.pubkey,
|
||||
nip05: user?.nip05,
|
||||
pubkey,
|
||||
nip05: user.nip05,
|
||||
signal,
|
||||
});
|
||||
},
|
||||
enabled: !!user,
|
||||
});
|
||||
|
||||
if (!user) {
|
||||
@@ -38,10 +44,8 @@ export function UserNip05({ className }: { className?: string }) {
|
||||
: user.nip05}
|
||||
</p>
|
||||
{!isLoading && verified ? (
|
||||
<VerifiedIcon className="size-5 text-teal-500" />
|
||||
) : (
|
||||
<UnverifiedIcon className="size-5 text-red-500" />
|
||||
)}
|
||||
<VerifiedIcon className="size-4 text-teal-500" />
|
||||
) : null}
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user