@@ -5,6 +5,21 @@ import type {
55import type { TimelineMessage } from "@/features/messages/types" ;
66import { UserAvatar } from "@/shared/ui/UserAvatar" ;
77
8+ function formatRelativeTime ( unixSeconds : number ) : string {
9+ const now = Date . now ( ) / 1_000 ;
10+ const diff = now - unixSeconds ;
11+
12+ if ( diff < 60 ) return "just now" ;
13+ if ( diff < 3_600 ) return `${ Math . floor ( diff / 60 ) } m` ;
14+ if ( diff < 86_400 ) return `${ Math . floor ( diff / 3_600 ) } h` ;
15+ if ( diff < 604_800 ) return `${ Math . floor ( diff / 86_400 ) } d` ;
16+
17+ return new Date ( unixSeconds * 1_000 ) . toLocaleDateString ( undefined , {
18+ month : "short" ,
19+ day : "numeric" ,
20+ } ) ;
21+ }
22+
823function ParticipantAvatar ( {
924 participant,
1025 index,
@@ -71,7 +86,7 @@ export function MessageThreadSummaryRow({
7186 ) : null }
7287
7388 < button
74- className = "inline-flex w-fit max-w-full items-center gap-1 rounded-full border border-border/70 bg-muted/70 py-0.5 pl-0.5 pr-2 text-left text-xs font-medium text-foreground/90 transition-colors hover:bg-accent hover:text-accent -foreground"
89+ className = "group inline-flex w-fit max-w-full items-center gap-1 text-left text-xs font-medium text-muted -foreground"
7590 data-thread-head-id = { message . id }
7691 data-testid = "message-thread-summary"
7792 onClick = { ( ) => onOpenThread ( message ) }
@@ -89,10 +104,15 @@ export function MessageThreadSummaryRow({
89104 </ div >
90105 < div className = "min-w-0" >
91106 < div className = "font-medium" >
92- < span >
107+ < span className = "transition-colors group-hover:text-foreground" >
93108 { summary . replyCount } { " " }
94109 { summary . replyCount === 1 ? "reply" : "replies" }
95110 </ span >
111+ { summary . lastReplyAt ? (
112+ < span className = "ml-1 text-muted-foreground/70" >
113+ last { formatRelativeTime ( summary . lastReplyAt ) }
114+ </ span >
115+ ) : null }
96116 </ div >
97117 </ div >
98118 </ button >
0 commit comments