@@ -34,13 +34,13 @@ function MessageItem({
3434 // Check if this is a system message
3535 const isSystemMessage = ! message . senderId || message . text . startsWith ( '$$system-message$$' ) ;
3636 // Remove the prefix for display
37- const displayText = isSystemMessage && message . text . startsWith ( '$$system-message$$' )
38- ? message . text . replace ( '$$system-message$$' , '' ) . trim ( )
37+ const displayText = isSystemMessage && message . text . startsWith ( '$$system-message$$' )
38+ ? message . text . replace ( '$$system-message$$' , '' ) . trim ( )
3939 : message . text ;
4040
4141
4242
43- if ( isSystemMessage ) {
43+ if ( isSystemMessage ) {
4444 return (
4545 < div className = "flex w-full justify-center my-4" >
4646 < div className = "max-w-[80%] text-center" >
@@ -63,14 +63,12 @@ function MessageItem({
6363
6464 return (
6565 < div
66- className = { `flex w-full ${
67- isOwnMessage ? 'justify-end' : 'justify-start'
68- } `}
66+ className = { `flex w-full ${ isOwnMessage ? 'justify-end' : 'justify-start'
67+ } `}
6968 >
7069 < div
71- className = { `flex max-w-[70%] ${
72- isOwnMessage ? 'flex-col items-end' : 'flex-col items-start'
73- } gap-1`}
70+ className = { `flex max-w-[70%] ${ isOwnMessage ? 'flex-col items-end' : 'flex-col items-start'
71+ } gap-1`}
7472 >
7573 { /* User Avatar and Name - Above the message */ }
7674 { ! isOwnMessage && showUserInfo && (
@@ -100,18 +98,16 @@ function MessageItem({
10098
10199 { /* Message Bubble */ }
102100 < div
103- className = { `rounded-2xl px-4 py-2 ${
104- isOwnMessage
105- ? 'bg-[#333399] text-white'
106- : 'bg-[#6600ff] text-white'
107- } ${ ! isOwnMessage ? 'ml-8' : '' } `}
101+ className = { `rounded-2xl px-4 py-2 ${ isOwnMessage
102+ ? 'bg-[#333399] text-white'
103+ : 'bg-[#6600ff] text-white'
104+ } ${ ! isOwnMessage ? 'ml-8' : '' } `}
108105 >
109106 < div className = 'break-words whitespace-pre-wrap' dangerouslySetInnerHTML = { { __html : displayText . replace ( / < a h r e f = " ( [ ^ " ] + ) " > ( [ ^ < ] + ) < \/ a > / g, '<a href="$1" class="text-blue-600 hover:text-blue-800 underline">$2</a>' ) } } />
110107 { showTime && message . createdAt ?. toDate && (
111108 < p
112- className = { `mt-1 text-xs ${
113- isOwnMessage ? 'text-white/70' : 'text-white/70'
114- } `}
109+ className = { `mt-1 text-xs ${ isOwnMessage ? 'text-white/70' : 'text-white/70'
110+ } `}
115111 >
116112 { formatDistanceToNow ( message . createdAt . toDate ( ) , {
117113 addSuffix : true
@@ -233,7 +229,7 @@ export function ChatWindow(): JSX.Element {
233229 try {
234230 await sendNewMessage ( messageText ) ;
235231 setMessageText ( '' ) ;
236- } catch ( error ) { }
232+ } catch ( error ) { }
237233 } ;
238234
239235 return (
@@ -273,13 +269,13 @@ export function ChatWindow(): JSX.Element {
273269 < p className = 'font-medium' >
274270 { getChatType ( currentChat ) === 'direct'
275271 ? otherUser ?. name ||
276- otherUser ?. username ||
277- otherParticipant
272+ otherUser ?. username ||
273+ otherParticipant
278274 : currentChat . name }
279275 </ p >
280276 < p className = 'text-sm text-gray-500 dark:text-gray-400' >
281277 { currentChat . type === 'direct'
282- ? otherUser ?. username
278+ ? otherUser ?. username
283279 ? `@${ otherUser . username } `
284280 : 'Direct Message'
285281 : `${ currentChat . participants . length } participants` }
@@ -330,7 +326,7 @@ export function ChatWindow(): JSX.Element {
330326 const showTime =
331327 ! nextMessage ||
332328 nextMessage . senderId !==
333- message . senderId ;
329+ message . senderId ;
334330
335331 // Show user info if:
336332 // 1. It's a group chat AND
@@ -341,22 +337,23 @@ export function ChatWindow(): JSX.Element {
341337 ! isOwnMessage &&
342338 ( ! prevMessage ||
343339 prevMessage . senderId !==
344- message . senderId ||
340+ message . senderId ||
345341 ( prevMessage . createdAt
346342 ?. toDate &&
347343 message . createdAt ?. toDate &&
348344 Math . abs (
349345 prevMessage . createdAt
350346 . toDate ( )
351347 . getTime ( ) -
352- message . createdAt
353- . toDate ( )
354- . getTime ( )
348+ message . createdAt
349+ . toDate ( )
350+ . getTime ( )
355351 ) >
356- 5 * 60 * 1000 ) ) ;
352+ 5 * 60 * 1000 ) ) ;
357353
358- const userData =
359- participantsData [ message . senderId ] ;
354+ const userData = message . senderId
355+ ? participantsData [ message . senderId ]
356+ : null ;
360357
361358 return (
362359 < MessageItem
0 commit comments