tweaks: Load mentions

Nip5 cleanup
This commit is contained in:
2023-01-16 22:22:21 +00:00
parent 238e6cd2f1
commit 1483fa6bb2
5 changed files with 30 additions and 13 deletions

21
src/element/Mention.tsx Normal file
View File

@ -0,0 +1,21 @@
import { useMemo } from "react";
import { Link } from "react-router-dom";
import useProfile from "../feed/ProfileFeed";
import { HexKey } from "../nostr";
import { hexToBech32, profileLink } from "../Util";
export default function Mention({ pubkey }: { pubkey: HexKey }) {
const user = useProfile(pubkey)?.get(pubkey);
const name = useMemo(() => {
let name = hexToBech32("npub", pubkey).substring(0, 12);
if ((user?.display_name?.length ?? 0) > 0) {
name = user!.display_name!;
} else if ((user?.name?.length ?? 0) > 0) {
name = user!.name!;
}
return name;
}, [user]);
return <Link to={profileLink(pubkey)} onClick={(e) => e.stopPropagation()}>@{name}</Link>
}