@@ -30,12 +30,16 @@ type ChatMessageHeaderProps = {
3030 * The message header component.
3131 */
3232export function ChatMessageHeader ( props : ChatMessageHeaderProps ) : JSX . Element {
33- // Don't render header for stacked messages or current user messages
34- if ( props . message . stacked || props . isCurrentUser ) {
33+ const message = props . message ;
34+ // Don't render header for stacked messages not deleted or edited.
35+ if ( message . stacked && ! message . deleted && ! message . edited ) {
3536 return < > </ > ;
3637 }
38+
39+ // Flag to display only the deleted or edited information (stacked message).
40+ const onlyState = message . stacked && ( message . deleted || message . edited ) ;
41+
3742 const [ datetime , setDatetime ] = useState < Record < number , string > > ( { } ) ;
38- const message = props . message ;
3943 const sender = message . sender ;
4044 /**
4145 * Effect: update cached datetime strings upon receiving a new message.
@@ -88,10 +92,10 @@ export function ChatMessageHeader(props: ChatMessageHeaderProps): JSX.Element {
8892 '& > :not(:last-child)' : {
8993 marginRight : 3
9094 } ,
91- marginBottom : message . stacked ? '0px' : '12px'
95+ marginBottom : message . stacked || props . isCurrentUser ? '0px' : '12px'
9296 } }
9397 >
94- { avatar }
98+ { ! props . isCurrentUser && ! onlyState && avatar }
9599 < Box
96100 sx = { {
97101 display : 'flex' ,
@@ -102,7 +106,7 @@ export function ChatMessageHeader(props: ChatMessageHeaderProps): JSX.Element {
102106 } }
103107 >
104108 < Box sx = { { display : 'flex' , alignItems : 'center' } } >
105- { ! message . stacked && (
109+ { ! onlyState && ! props . isCurrentUser && (
106110 < Typography
107111 sx = { {
108112 fontWeight : 700 ,
@@ -124,17 +128,19 @@ export function ChatMessageHeader(props: ChatMessageHeaderProps): JSX.Element {
124128 </ Typography >
125129 ) }
126130 </ Box >
127- < Typography
128- className = { MESSAGE_TIME_CLASS }
129- sx = { {
130- fontSize : '0.8em' ,
131- color : 'var(--jp-ui-font-color2)' ,
132- fontWeight : 300
133- } }
134- title = { message . raw_time ? 'Unverified time' : '' }
135- >
136- { `${ datetime [ message . time ] } ${ message . raw_time ? '*' : '' } ` }
137- </ Typography >
131+ { ! onlyState && (
132+ < Typography
133+ className = { MESSAGE_TIME_CLASS }
134+ sx = { {
135+ fontSize : '0.8em' ,
136+ color : 'var(--jp-ui-font-color2)' ,
137+ fontWeight : 300
138+ } }
139+ title = { message . raw_time ? 'Unverified time' : '' }
140+ >
141+ { `${ datetime [ message . time ] } ${ message . raw_time ? '*' : '' } ` }
142+ </ Typography >
143+ ) }
138144 </ Box >
139145 </ Box >
140146 ) ;
0 commit comments