Skip to content

Commit d1cda75

Browse files
committed
Date refinements. Show more detailed timestamps for older messages, and try to show a separator as the first message in every room
1 parent 530b077 commit d1cda75

2 files changed

Lines changed: 24 additions & 1 deletion

File tree

‎src/controllers/organisms/RoomView.js‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,13 @@ module.exports = {
398398
continuation = false;
399399
}
400400
}
401+
402+
if (i === 1) { // n.b. 1, not 0, as the 0th event is an m.room.create and so doesn't show on the timeline
403+
var ts1 = this.state.room.timeline[i].getTs();
404+
dateSeparator = <DateSeparator key={ts1} ts={ts1}/>;
405+
continuation = false;
406+
}
407+
401408
if (!TileType) continue;
402409
ret.unshift(
403410
<li key={mxEv.getId()}><TileType mxEvent={mxEv} continuation={continuation} last={last}/></li>

‎src/skins/vector/views/atoms/MessageTimestamp.js‎

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ var React = require('react');
2020

2121
var MessageTimestampController = require('matrix-react-sdk/lib/controllers/atoms/MessageTimestamp')
2222

23+
var days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
24+
var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
25+
2326
module.exports = React.createClass({
2427
displayName: 'MessageTimestamp',
2528
mixins: [MessageTimestampController],
@@ -30,7 +33,20 @@ module.exports = React.createClass({
3033
function pad(n) {
3134
return (n < 10 ? '0' : '') + n;
3235
}
33-
return pad(date.getHours()) + ':' + pad(date.getMinutes());
36+
37+
var now = new Date();
38+
if (date.toDateString() === now.toDateString()) {
39+
return pad(date.getHours()) + ':' + pad(date.getMinutes());
40+
}
41+
else if (now.getTime() - date.getTime() < 6 * 24 * 60 * 60 * 1000) {
42+
return days[date.getDay()] + " " + pad(date.getHours()) + ':' + pad(date.getMinutes());
43+
}
44+
else if (now.getFullYear() === date.getFullYear()) {
45+
return days[date.getDay()] + ", " + months[date.getMonth()] + " " + (date.getDay()+1) + " " + pad(date.getHours()) + ':' + pad(date.getMinutes());
46+
}
47+
else {
48+
return days[date.getDay()] + ", " + months[date.getMonth()] + " " + (date.getDay()+1) + " " + date().getFullYear() + " " + pad(date.getHours()) + ':' + pad(date.getMinutes());
49+
}
3450
},
3551

3652
render: function() {

0 commit comments

Comments
 (0)