Remove remaining genUserName references from docs and skill templates

This commit is contained in:
Alex Gleason committed 2026-05-30 18:44:53 +02:00
1 parent 881629a746
commit 2b7d6655af
5 files changed
+8 -13

No files matched your search

@@ -40,7 +40,6 @@ import {
Trash2,
} from 'lucide-react';
import { formatDistanceToNow } from 'date-fns';
import { genUserName } from '@/lib/genUserName';
interface CommentProps {
root: NostrEvent | URL | `#${string}`;
@@ -63,7 +62,7 @@ export function Comment({ root, comment, depth = 0, maxDepth = 3, limit }: Comme
const queryClient = useQueryClient();
const metadata = author.data?.metadata;
const displayName = metadata?.name ?? genUserName(comment.pubkey);
const displayName = metadata?.name ?? 'Anonymous';
const timeAgo = formatDistanceToNow(new Date(comment.created_at * 1000), { addSuffix: true });
const nevent = nip19.neventEncode({ id: comment.id, author: comment.pubkey, kind: comment.kind });
const isOwnComment = user?.pubkey === comment.pubkey;
+1 -2
View File
@@ -176,11 +176,10 @@ The stubs shipped here are deliberately minimal so the skill works immediately a
## Tests
`NoteContent.test.tsx` covers URL linkification (kinds 1 and 1111), plain text, hashtag linkification, and mention rendering with generated vs real display names. It uses the template's `TestApp` wrapper. Run via `npm run test` once the files are in `src/`.
`NoteContent.test.tsx` covers URL linkification (kinds 1 and 1111), plain text, hashtag linkification, and mention rendering with fallback vs real display names. It uses the template's `TestApp` wrapper. Run via `npm run test` once the files are in `src/`.
## Related
- **`useAuthor`** — used internally for mention resolution and for audio-embed author avatar. Core template.
- **`genUserName`** — fallback deterministic name when a mentioned user has no kind 0 metadata. Core template.
- **`NIP19Page`** — the template's `/:nip19` route that handles every kind of NIP-19 link this component generates.
- **`nwc` skill** — pair with `LightningInvoiceCard` for one-tap invoice payment via WebLN/NWC.
@@ -3,7 +3,6 @@ import { type NostrEvent } from '@nostrify/nostrify';
import { Link } from 'react-router-dom';
import { nip19 } from 'nostr-tools';
import { useAuthor } from '@/hooks/useAuthor';
import { genUserName } from '@/lib/genUserName';
import { getDisplayName } from '@/lib/getDisplayName';
import { getAvatarShape } from '@/lib/avatarShape';
import { useProfileUrl } from '@/hooks/useProfileUrl';
@@ -532,7 +531,7 @@ export function NoteContent({
const author = useAuthor(hasMedia ? event.pubkey : undefined);
const authorMetadata = author.data?.metadata;
const authorDisplayName = useMemo(
() => getDisplayName(authorMetadata, event.pubkey) ?? genUserName(event.pubkey),
() => getDisplayName(authorMetadata, event.pubkey),
[authorMetadata, event.pubkey],
);
@@ -843,7 +842,7 @@ function InlineImage({ url, onClick }: { url: string; onClick: (e: React.MouseEv
function NostrMention({ pubkey }: { pubkey: string }) {
const author = useAuthor(pubkey);
const hasRealName = !!author.data?.metadata?.name;
const displayName = author.data?.metadata?.name ?? genUserName(pubkey);
const displayName = author.data?.metadata?.name ?? 'Anonymous';
const profileUrl = useProfileUrl(pubkey, author.data?.metadata);
return (
@@ -1,15 +1,14 @@
import { genUserName } from '@/lib/genUserName';
import type { NostrMetadata } from '@nostrify/nostrify';
/**
* Get a display name for a user.
* Uses metadata.name if available, otherwise generates a deterministic username.
* Uses metadata.name if available, otherwise falls back to "Anonymous".
* Visual truncation is handled by CSS (`truncate` class) on the containing element
* to avoid breaking NIP-30 custom emoji shortcodes.
*/
export function getDisplayName(
metadata: NostrMetadata | undefined,
pubkey: string,
_pubkey: string,
): string {
return metadata?.name || genUserName(pubkey);
return metadata?.name || 'Anonymous';
}
+1 -2
View File
@@ -155,13 +155,12 @@ Fetch profile metadata (kind 0) for a pubkey:
```tsx
import type { NostrEvent, NostrMetadata } from '@nostrify/nostrify';
import { useAuthor } from '@/hooks/useAuthor';
import { genUserName } from '@/lib/genUserName';
function Post({ event }: { event: NostrEvent }) {
const author = useAuthor(event.pubkey);
const metadata: NostrMetadata | undefined = author.data?.metadata;
const displayName = metadata?.name ?? genUserName(event.pubkey);
const displayName = metadata?.name ?? 'Anonymous';
const profileImage = metadata?.picture;
// ...
}