reimplement 1a95148dae which somehow got lost during refactoring vector-web into matrix-react-sdk and vector-web

This commit is contained in:
Matthew Hodgson 2015-10-19 17:13:40 +01:00
parent 11aa6f8c37
commit 530b077a8e
1 changed files with 13 additions and 0 deletions

View File

@ -365,6 +365,8 @@ module.exports = {
'm.room.topic' : sdk.getComponent('molecules.EventAsTextTile'), 'm.room.topic' : sdk.getComponent('molecules.EventAsTextTile'),
}; };
var DateSeparator = sdk.getComponent('molecules.DateSeparator');
var ret = []; var ret = [];
var count = 0; var count = 0;
@ -373,6 +375,7 @@ module.exports = {
var TileType = tileTypes[mxEv.getType()]; var TileType = tileTypes[mxEv.getType()];
var continuation = false; var continuation = false;
var last = false; var last = false;
var dateSeparator = null;
if (i == this.state.room.timeline.length - 1) { if (i == this.state.room.timeline.length - 1) {
last = true; last = true;
} }
@ -387,11 +390,21 @@ module.exports = {
{ {
continuation = true; continuation = true;
} }
var ts0 = this.state.room.timeline[i - 1].getTs();
var ts1 = this.state.room.timeline[i].getTs();
if (new Date(ts0).toDateString() !== new Date(ts1).toDateString()) {
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>
); );
if (dateSeparator) {
ret.unshift(dateSeparator);
}
++count; ++count;
} }
return ret; return ret;