Use 'today' for the date separator for unsent messages

Fixes https://github.com/vector-im/vector-web/issues/1087, though we'll still
have problems if the unsent messages get out of order.
This commit is contained in:
Richard van der Hoff 2016-03-10 14:16:31 +00:00
parent ec2e27a754
commit 928b2bb9a7

View file

@ -259,12 +259,15 @@ module.exports = React.createClass({
continuation = true; 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(); var ts1 = mxEv.getTs();
if ((prevEvent == null && !this.props.suppressFirstDateSeparator) || if (mxEv.status) {
(prevEvent != null && ts1 = new Date();
new Date(prevEvent.getTs()).toDateString() }
!== new Date(ts1).toDateString())) {
// 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>; var dateSeparator = <li key={ts1}><DateSeparator key={ts1} ts={ts1}/></li>;
ret.push(dateSeparator); ret.push(dateSeparator);
continuation = false; continuation = false;
@ -290,6 +293,17 @@ module.exports = React.createClass({
return ret; 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) { _getReadMarkerTile: function(visible) {
var hr; var hr;
if (visible) { if (visible) {