|
19 | 19 | <div v-if="message.first_in_timespan" |
20 | 20 | v-bind:class="{'text-center': true, 'mx-auto': true, 'mt-8': index !== 0}"> |
21 | 21 | <h1 |
22 | | - class="text-xs font-light inline-block rounded-md bg-gray-200 px-2 py-1">{{message.timestamp_ago}}</h1> |
| 22 | + class="text-xs font-light inline-block rounded-md bg-gray-200 px-2 py-1">{{message.timestamp_first}}</h1> |
23 | 23 | </div> |
24 | 24 | <MessageBubble |
25 | 25 | v-bind:loggedInUserId="loggedInUserId" |
@@ -61,16 +61,22 @@ export default { |
61 | 61 | determineFirstMessagesOfTimespans(messages) { |
62 | 62 | const len = messages.length; |
63 | 63 | for (let i = 0; i < len; i += 1) { |
64 | | - if (this.displayDate(messages[i].timestamp_ago)) { |
| 64 | + if (this.displayDate(messages[i].timestamp)) { |
65 | 65 | messages[i].first_in_timespan = true; |
| 66 | + messages[i].timestamp_first = this.getDayMonthday(messages[i].timestamp); |
66 | 67 | } else { |
67 | 68 | messages[i].first_in_timespan = false; |
68 | 69 | } |
69 | 70 | } |
70 | 71 | }, |
71 | | - displayDate(messageAgo) { |
72 | | - if (messageAgo !== this.latestMessagesDate) { |
73 | | - this.latestMessagesDate = messageAgo; |
| 72 | + getDayMonthday(timestamp) { |
| 73 | + const splitBySpace = timestamp.split(' '); |
| 74 | + return `${splitBySpace[0]} ${splitBySpace[1]} ${splitBySpace[2]}`; |
| 75 | + }, |
| 76 | + displayDate(timestamp) { |
| 77 | + const dayMonthday = this.getDayMonthday(timestamp); |
| 78 | + if (dayMonthday !== this.latestMessagesDate) { |
| 79 | + this.latestMessagesDate = dayMonthday; |
74 | 80 | return (1); |
75 | 81 | } |
76 | 82 | return (0); |
|
0 commit comments