2023-10-17 13:02:59 +00:00
|
|
|
import { NostrLink, NostrPrefix } from "@snort/system";
|
2023-06-16 19:31:33 +00:00
|
|
|
import { useUserProfile } from "@snort/system-react";
|
2023-10-17 22:01:53 +00:00
|
|
|
import { useHover } from "@uidotdev/usehooks";
|
2023-03-25 22:55:34 +00:00
|
|
|
|
2023-11-17 11:52:10 +00:00
|
|
|
import DisplayName from "@/Element/User/DisplayName";
|
|
|
|
import { ProfileCard } from "@/Element/User/ProfileCard";
|
|
|
|
import { ProfileLink } from "@/Element/User/ProfileLink";
|
2023-10-17 13:02:59 +00:00
|
|
|
|
|
|
|
export default function Mention({ link }: { link: NostrLink }) {
|
2023-10-17 22:01:53 +00:00
|
|
|
const [ref, hovering] = useHover<HTMLAnchorElement>();
|
2023-10-17 13:02:59 +00:00
|
|
|
const profile = useUserProfile(link.id);
|
|
|
|
|
|
|
|
if (link.type !== NostrPrefix.Profile && link.type !== NostrPrefix.PublicKey) return;
|
2023-01-16 22:22:21 +00:00
|
|
|
|
2023-02-07 20:04:50 +00:00
|
|
|
return (
|
2023-10-17 22:01:53 +00:00
|
|
|
<>
|
2023-11-17 21:50:12 +00:00
|
|
|
<ProfileLink pubkey={link.id} link={link} user={profile} onClick={e => e.stopPropagation()}>
|
2023-10-17 22:01:53 +00:00
|
|
|
<span ref={ref}>
|
|
|
|
@<DisplayName user={profile} pubkey={link.id} />
|
|
|
|
</span>
|
|
|
|
</ProfileLink>
|
|
|
|
<ProfileCard pubkey={link.id} user={profile} show={hovering} ref={ref} />
|
|
|
|
</>
|
2023-02-07 20:04:50 +00:00
|
|
|
);
|
2023-01-27 21:38:41 +00:00
|
|
|
}
|