diff --git a/src/components/topic-detail-client.test.tsx b/src/components/topic-detail-client.test.tsx index 912441e..edc0b7c 100644 --- a/src/components/topic-detail-client.test.tsx +++ b/src/components/topic-detail-client.test.tsx @@ -234,7 +234,8 @@ describe('TopicDetailClient', () => { await user.click(screen.getByRole('button', { name: /reply to this topic/i })) // The composer should expand and show the reply target banner with the topic author - expect(screen.getByText(`Replying to @${topic.authorDid}`)).toBeInTheDocument() + const expectedHandle = topic.author?.handle ?? topic.authorDid + expect(screen.getByText(`Replying to @${expectedHandle}`)).toBeInTheDocument() }) it('clears reply target when dismiss button is clicked', async () => { diff --git a/src/components/topic-detail-client.tsx b/src/components/topic-detail-client.tsx index af6da0b..5aa0798 100644 --- a/src/components/topic-detail-client.tsx +++ b/src/components/topic-detail-client.tsx @@ -112,7 +112,7 @@ export function TopicDetailClient({ topic, replies, isLocked = false }: TopicDet handleReply({ uri: topic.uri, cid: topic.cid, - authorHandle: topic.authorDid, + authorHandle: topic.author?.handle ?? topic.authorDid, snippet: topic.content.slice(0, 100), }) : undefined diff --git a/src/components/topic-view.test.tsx b/src/components/topic-view.test.tsx index 138bce4..b2042ca 100644 --- a/src/components/topic-view.test.tsx +++ b/src/components/topic-view.test.tsx @@ -63,8 +63,16 @@ describe('TopicView', () => { expect(screen.getByText(topic.content)).toBeInTheDocument() }) - it('renders author handle', () => { + it('renders author display name with link', () => { render() + expect(screen.getByText('Jay')).toBeInTheDocument() + const authorLink = screen.getByRole('link', { name: /Jay/ }) + expect(authorLink).toHaveAttribute('href', `/u/${mockUsers[0]!.handle}`) + }) + + it('falls back to DID when author profile is missing', () => { + const topicWithoutAuthor = { ...topic, author: undefined } + render() expect(screen.getByText(mockUsers[0]!.did)).toBeInTheDocument() }) diff --git a/src/components/topic-view.tsx b/src/components/topic-view.tsx index 137c069..a89d8c1 100644 --- a/src/components/topic-view.tsx +++ b/src/components/topic-view.tsx @@ -6,6 +6,7 @@ */ import Link from 'next/link' +import Image from 'next/image' import { ChatCircle, Clock, @@ -108,7 +109,28 @@ export function TopicView({ {/* Author + timestamp */}
- {topic.authorDid} + + {topic.author?.avatarUrl ? ( + + ) : ( + + )} + {topic.author?.displayName ?? topic.author?.handle ?? topic.authorDid} + {isEdited(topic.createdAt, topic.indexedAt) && (