-
Notifications
You must be signed in to change notification settings - Fork 0
/
TheirMessage.jsx
30 lines (28 loc) · 1.02 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
const TheirMessage = ({ lastMessage, message }) => {
const isFirstMessageByUser = !lastMessage || lastMessage.sender.username !== message.sender.username;
return (
<div className="message-row">
{isFirstMessageByUser && (
<div
className="message-avatar"
style={{ backgroundImage: message.sender && `url(${message.sender.avatar})` }}
/>
)}
{message.attachments && 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: '#CABCDC', marginLeft: isFirstMessageByUser ? '4px' : '48px' }}>
{message.text}
</div>
)}
</div>
);
};
export default TheirMessage;