refactor: declare format timestamp as variable for consistency
This commit is contained in:
parent
1c03e83c31
commit
8c380f118a
@ -16,6 +16,7 @@ export default class Message extends Component {
|
||||
const { image, author, body, timestamp } = message;
|
||||
const formattedMessage = formatMessageText(body, username);
|
||||
const avatar = image || generateAvatar(author);
|
||||
const formattedTimestamp = formatTimestamp(timestamp);
|
||||
|
||||
const authorColor = messageBubbleColorForString(author);
|
||||
const avatarBgColor = { backgroundColor: authorColor };
|
||||
@ -35,7 +36,7 @@ export default class Message extends Component {
|
||||
</div>
|
||||
<div
|
||||
class="message-text text-gray-300 font-normal overflow-y-hidden"
|
||||
title=${`Sent at ${formatTimestamp(timestamp)}`}
|
||||
title=${formattedTimestamp}
|
||||
dangerouslySetInnerHTML=${
|
||||
{ __html: formattedMessage }
|
||||
}
|
||||
|
@ -284,9 +284,9 @@ export function formatTimestamp(sentAt) {
|
||||
|
||||
let diffInDays = ((new Date()) - sentAt) / (24 * 3600 * 1000);
|
||||
if (diffInDays >= 1) {
|
||||
return `${sentAt.toLocaleDateString('en-US', {dateStyle: 'medium'})} at ` +
|
||||
return `Sent at ${sentAt.toLocaleDateString('en-US', {dateStyle: 'medium'})} at ` +
|
||||
sentAt.toLocaleTimeString();
|
||||
}
|
||||
|
||||
return sentAt.toLocaleTimeString();
|
||||
return `Sent at ${sentAt.toLocaleTimeString()}`;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user