Date refinements. Show more detailed timestamps for older messages, and try to show a separator as the first message in every room

This commit is contained in:
Matthew Hodgson 2015-10-19 18:19:26 +01:00
parent 530b077a8e
commit d1cda75c8b
2 changed files with 24 additions and 1 deletions

View File

@ -398,6 +398,13 @@ module.exports = {
continuation = false; continuation = false;
} }
} }
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
var ts1 = this.state.room.timeline[i].getTs();
dateSeparator = <DateSeparator key={ts1} ts={ts1}/>;
continuation = false;
}
if (!TileType) continue; if (!TileType) continue;
ret.unshift( ret.unshift(
<li key={mxEv.getId()}><TileType mxEvent={mxEv} continuation={continuation} last={last}/></li> <li key={mxEv.getId()}><TileType mxEvent={mxEv} continuation={continuation} last={last}/></li>

View File

@ -20,6 +20,9 @@ var React = require('react');
var MessageTimestampController = require('matrix-react-sdk/lib/controllers/atoms/MessageTimestamp') var MessageTimestampController = require('matrix-react-sdk/lib/controllers/atoms/MessageTimestamp')
var days = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"];
var months = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
module.exports = React.createClass({ module.exports = React.createClass({
displayName: 'MessageTimestamp', displayName: 'MessageTimestamp',
mixins: [MessageTimestampController], mixins: [MessageTimestampController],
@ -30,7 +33,20 @@ module.exports = React.createClass({
function pad(n) { function pad(n) {
return (n < 10 ? '0' : '') + n; return (n < 10 ? '0' : '') + n;
} }
var now = new Date();
if (date.toDateString() === now.toDateString()) {
return pad(date.getHours()) + ':' + pad(date.getMinutes()); return pad(date.getHours()) + ':' + pad(date.getMinutes());
}
else if (now.getTime() - date.getTime() < 6 * 24 * 60 * 60 * 1000) {
return days[date.getDay()] + " " + pad(date.getHours()) + ':' + pad(date.getMinutes());
}
else if (now.getFullYear() === date.getFullYear()) {
return days[date.getDay()] + ", " + months[date.getMonth()] + " " + (date.getDay()+1) + " " + pad(date.getHours()) + ':' + pad(date.getMinutes());
}
else {
return days[date.getDay()] + ", " + months[date.getMonth()] + " " + (date.getDay()+1) + " " + date().getFullYear() + " " + pad(date.getHours()) + ':' + pad(date.getMinutes());
}
}, },
render: function() { render: function() {