feat: link names to profiles

This commit is contained in:
Eric P
2025-03-01 20:31:56 -06:00
parent cbe7f742b9
commit d91fa21908
5 changed files with 28 additions and 8 deletions

View File

@ -40,9 +40,14 @@ function TopStreamer({ pubkey, amount }: { pubkey: string; amount: number }) {
<Link to={profileLink(profile, pubkey)}> <Link to={profileLink(profile, pubkey)}>
<Avatar pubkey={pubkey} user={profile} size={56} /> <Avatar pubkey={pubkey} user={profile} size={56} />
</Link> </Link>
<div className="flex flex-col"> <div className="flex flex-col">
<div className="text-zap text-xl font-medium">{formatSatsCompact(amount)}</div> <div className="text-zap text-xl font-medium">{formatSatsCompact(amount)}</div>
<div className="whitespace-nowrap">{getName(pubkey, profile)}</div> <div className="whitespace-nowrap">
<Link to={profileLink(profile, pubkey)} className="hover:underline">
{getName(pubkey, profile)}
</Link>
</div>
</div> </div>
</div> </div>
); );

View File

@ -1,5 +1,5 @@
import { findTag, profileLink } from "@/utils"; import { findTag, profileLink } from "@/utils";
import { NostrEvent } from "@snort/system"; import { NostrEvent, NostrLink } from "@snort/system";
import { useUserProfile } from "@snort/system-react"; import { useUserProfile } from "@snort/system-react";
import { FormattedMessage } from "react-intl"; import { FormattedMessage } from "react-intl";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
@ -9,6 +9,7 @@ export function ClipTile({ ev }: { ev: NostrEvent }) {
const profile = useUserProfile(ev.pubkey); const profile = useUserProfile(ev.pubkey);
const r = findTag(ev, "r"); const r = findTag(ev, "r");
const title = findTag(ev, "title"); const title = findTag(ev, "title");
return ( return (
<div className="h-full flex flex-col gap-4 bg-layer-1 rounded-xl px-3 py-2"> <div className="h-full flex flex-col gap-4 bg-layer-1 rounded-xl px-3 py-2">
<span> <span>
@ -16,7 +17,7 @@ export function ClipTile({ ev }: { ev: NostrEvent }) {
defaultMessage="Clip by {name}" defaultMessage="Clip by {name}"
values={{ values={{
name: ( name: (
<Link to={profileLink(profile, ev.pubkey)} className="font-medium text-primary"> <Link to={profileLink(profile, ev.pubkey)} className="font-medium text-primary hover:underline">
{getName(ev.pubkey, profile)} {getName(ev.pubkey, profile)}
</Link> </Link>
), ),

View File

@ -87,11 +87,15 @@ export function StreamTile({
)} )}
<div className="flex flex-col break-words min-w-0"> <div className="flex flex-col break-words min-w-0">
<span className="font-medium" title={title}> <span className="font-medium" title={title}>
{(title?.length ?? 0) > 50 ? `${title?.slice(0, 47)}...` : title} <Link to={`/${link.encode()}`} state={ev}>
{(title?.length ?? 0) > 50 ? `${title?.slice(0, 47)}...` : title}
</Link>
</span> </span>
{showAuthor && ( {showAuthor && (
<span className="text-layer-4"> <span className="text-layer-4">
{getName(host, hostProfile)} <Link to={profileLink(hostProfile, host)} className="hover:underline">
{getName(host, hostProfile)}
</Link>
{ends && ( {ends && (
<> <>
{" · "} {" · "}

View File

@ -4,6 +4,8 @@ import { Text } from "@/element/text";
import { useUserProfile } from "@snort/system-react"; import { useUserProfile } from "@snort/system-react";
import EventReactions from "../event-reactions"; import EventReactions from "../event-reactions";
import { RelativeTime } from "../relative-time"; import { RelativeTime } from "../relative-time";
import { Link } from "react-router-dom";
import { profileLink } from "@/utils";
export default function VideoComment({ ev }: { ev: TaggedNostrEvent }) { export default function VideoComment({ ev }: { ev: TaggedNostrEvent }) {
const profile = useUserProfile(ev.pubkey); const profile = useUserProfile(ev.pubkey);
@ -19,7 +21,11 @@ export default function VideoComment({ ev }: { ev: TaggedNostrEvent }) {
/> />
<div className="flex flex-col gap-1"> <div className="flex flex-col gap-1">
<div className="font-medium flex gap-2 items-center"> <div className="font-medium flex gap-2 items-center">
<div>{getName(ev.pubkey, profile)}</div> <div>
<Link to={profileLink(profile, ev.pubkey)} className="hover:underline">
{getName(ev.pubkey, profile)}
</Link>
</div>
<div className="text-neutral-500 text-sm"> <div className="text-neutral-500 text-sm">
<RelativeTime from={ev.created_at * 1000} /> <RelativeTime from={ev.created_at * 1000} />
</div> </div>

View File

@ -87,11 +87,15 @@ export function VideoTile({
)} )}
<div className="flex flex-col break-words min-w-0"> <div className="flex flex-col break-words min-w-0">
<span className="font-medium" title={video.title}> <span className="font-medium" title={video.title}>
{(video.title?.length ?? 0) > 50 ? `${video.title?.slice(0, 47)}...` : video.title} <Link to={`/${link.encode()}`} state={ev}>
{(video.title?.length ?? 0) > 50 ? `${video.title?.slice(0, 47)}...` : video.title}
</Link>
</span> </span>
{showAuthor && ( {showAuthor && (
<span className="text-layer-4"> <span className="text-layer-4">
{getName(host, hostProfile)} <Link to={profileLink(hostProfile, host)} className="hover:underline">
{getName(host, hostProfile)}
</Link>
{video.publishedAt && ( {video.publishedAt && (
<> <>
{" · "} {" · "}