/** @jsx h */ import { h } from "https://esm.sh/preact@10.17.1"; import { Avatar } from "./components/avatar.tsx"; import { PublicKey } from "../../libs/nostr.ts/key.ts"; import { ProfileData } from "../features/profile.ts"; import { emitFunc } from "../event-bus.ts"; import { DirectMessagePanelUpdate } from "./message-panel.tsx"; import { HomeIcon } from "./icons/home-icon.tsx"; import { KeyIcon } from "./icons/key-icon.tsx"; import { UserIcon } from "./icons/user-icon.tsx"; import { CopyButton } from "./components/copy-button.tsx"; import { LinkColor } from "./style/colors.ts"; import { findUrlInString } from "./message.ts"; import { SelectConversation } from "./search_model.ts"; import { CloseRightPanel } from "./components/right-panel.tsx"; import { robohash } from "../../libs/nostr.ts/nip11.ts"; export type BlockUser = { type: "BlockUser"; pubkey: PublicKey; }; export type UnblockUser = { type: "UnblockUser"; pubkey: PublicKey; }; type UserDetailProps = { targetUserProfile: ProfileData; pubkey: PublicKey; blocked: boolean; emit: emitFunc; }; export function UserDetail(props: UserDetailProps) { const name = props.targetUserProfile.name || props.targetUserProfile.display_name || props.pubkey.bech32(); return (

{ props.emit({ type: "SelectConversation", pubkey: props.pubkey, }); props.emit({ type: "CloseRightPanel", }); }} > {name}

{props.pubkey.bech32()}

{props.pubkey.hex}

{props.targetUserProfile.about ? (

{TextWithLinks({ text: props.targetUserProfile.about })}

) : undefined} {props.targetUserProfile.website ? (

{TextWithLinks({ text: props.targetUserProfile.website })}

) : undefined}
{ if (props.blocked) { props.emit({ type: "UnblockUser", pubkey: props.pubkey, }); } else { props.emit({ type: "BlockUser", pubkey: props.pubkey, }); } }} > {props.blocked ? "Unblock" : "Block"}
); } function TextWithLinks({ text }: { text: string }) { const parts = findUrlInString(text); return (
{parts.map((part, index) => { if (part instanceof URL) { return ( {part.href} ); } else { return {part}; } })}
); }