Limit the number of messages we load into a chat room when we switch to it (or more accurately, switch back to it).

This commit is contained in:
David Baker 2015-06-25 14:36:24 +01:00
parent 2355d5e6b5
commit 209e052025
2 changed files with 28 additions and 12 deletions

View file

@ -38,11 +38,16 @@ module.exports = React.createClass({
mixins: [RoomViewController],
getMessageTiles: function() {
return this.state.room.timeline.map(function(mxEv) {
return (
var ret = [];
var count = 0;
for (var i = this.state.room.timeline.length-1; i >= 0 && count < this.state.messageCap; --i) {
var mxEv = this.state.room.timeline[i];
ret.unshift(
<li key={mxEv.getId()}><MessageTile mxEvent={mxEv} /></li>
);
});
++count;
}
return ret;
},
render: function() {