Merge pull request #209 from matrix-org/rav/local_echoes_are_today

Use 'today' for the date separator for unsent messages
This commit is contained in:
Richard van der Hoff 2016-03-10 14:34:18 +00:00
commit 7660276b54

View file

@ -259,12 +259,15 @@ module.exports = React.createClass({
continuation = true;
}
// do we need a date separator since the last event?
// local echoes have a fake date, which could even be yesterday. Treat them
// as 'today' for the date separators.
var ts1 = mxEv.getTs();
if ((prevEvent == null && !this.props.suppressFirstDateSeparator) ||
(prevEvent != null &&
new Date(prevEvent.getTs()).toDateString()
!== new Date(ts1).toDateString())) {
if (mxEv.status) {
ts1 = new Date();
}
// do we need a date separator since the last event?
if (this._wantsDateSeparator(prevEvent, ts1)) {
var dateSeparator = <li key={ts1}><DateSeparator key={ts1} ts={ts1}/></li>;
ret.push(dateSeparator);
continuation = false;
@ -290,6 +293,17 @@ module.exports = React.createClass({
return ret;
},
_wantsDateSeparator: function(prevEvent, nextEventTs) {
if (prevEvent == null) {
// first event in the panel: depends if we could back-paginate from
// here.
return !this.props.suppressFirstDateSeparator;
}
return (new Date(prevEvent.getTs()).toDateString()
!== new Date(nextEventTs).toDateString());
},
_getReadMarkerTile: function(visible) {
var hr;
if (visible) {