-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTheirMessage.jsx
39 lines (30 loc) · 1.23 KB
/
TheirMessage.jsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
const TheirMessage = ({lastMessage, message }) => {
/*----to check if it the first msg by the user ------*/
const isFirstMessageByUser = ! lastMessage || lastMessage.sender.username !== message.sender.username;
return(
<div className="message-row">
{isFirstMessageByUser &&(
<div
className="message-avatar"
style={{backgroundImage: "url(${message?.sender?.avatar})"}}
/>
)}
{
message?.attachments?.length > 0
? (
<img
src={message.attachments[0].file}
alt="message-attachment"
className="message-image"
style={{marginLeft: isFirstMessageByUser ? '4px' : '48px' }}
/>
) : (
<div className="message" style={{float: 'left', backgroundColor: '#6a8af3' }}>
{message.text}
</div>
)
}
</div>
)
}
export default TheirMessage;