Add date seperator to the expanded events

netsplits across midnight is not handled, and @richvdh suggested splitting the list in two
This commit is contained in:
Luke Barnard 2016-11-09 17:44:43 +00:00
parent 04a934f738
commit 5f0b891d47
2 changed files with 7 additions and 8 deletions

View file

@ -294,7 +294,6 @@ module.exports = React.createClass({
// Wrap consecutive member events in a ListSummary // Wrap consecutive member events in a ListSummary
if (isMembershipChange(mxEv)) { if (isMembershipChange(mxEv)) {
let summarisedEvents = [mxEv]; let summarisedEvents = [mxEv];
i++; i++;
for (;i < this.props.events.length; i++) { for (;i < this.props.events.length; i++) {
@ -306,15 +305,14 @@ module.exports = React.createClass({
} }
summarisedEvents.push(collapsedMxEv); summarisedEvents.push(collapsedMxEv);
} }
let renderEvents = (pEvent, events) => {
let renderEvents = (events) => {
if (events.length === 0) { if (events.length === 0) {
return null; return null;
} }
return events.map( return events.map(
(e) => { (e) => {
// e, e to prevent date seperators let ret = this._getTilesForEvent(pEvent, e);
let ret = this._getTilesForEvent(e, e); pEvent = e;
return ret; return ret;
} }
).reduce((a,b) => a.concat(b)); ).reduce((a,b) => a.concat(b));
@ -322,11 +320,11 @@ module.exports = React.createClass({
ret.push( ret.push(
<MemberEventListSummary <MemberEventListSummary
events={summarisedEvents} events={summarisedEvents}
previousEvent={prevEvent}
renderEvents={renderEvents} renderEvents={renderEvents}
/> />
); );
// Use the first member event to create scroll token prevEvent = mxEv;
ret.push(<li key={eventId} data-scroll-token={eventId}/>);
continue; continue;
} }

View file

@ -31,6 +31,7 @@ module.exports = React.createClass({
threshold: React.PropTypes.number, threshold: React.PropTypes.number,
// The function to render events if they are not being summarised // The function to render events if they are not being summarised
renderEvents: React.PropTypes.function, renderEvents: React.PropTypes.function,
previousEvent: React.PropTypes.object,
}, },
getInitialState: function() { getInitialState: function() {
@ -190,7 +191,7 @@ module.exports = React.createClass({
let expandedEvents = null; let expandedEvents = null;
if (expanded) { if (expanded) {
expandedEvents = this.props.renderEvents(eventsToRender); expandedEvents = this.props.renderEvents(this.props.previousEvent, eventsToRender);
} }
let avatars = this.renderAvatars(joinEvents.concat(leaveEvents)); let avatars = this.renderAvatars(joinEvents.concat(leaveEvents));