From 3eb87e2aa30129b49208b0418782c1457102b775 Mon Sep 17 00:00:00 2001 From: Michael Telatynski <7t3chguy@gmail.com> Date: Wed, 26 Jul 2017 12:17:05 +0100 Subject: [PATCH] change lastShownEventIndex -> lastShownEvent since some places do not have the same i reference (namely MELS generation) this way a member event at bottom of MELS (if is the last event in the timeline will have last set appropriately) --- src/components/structures/MessagePanel.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/components/structures/MessagePanel.js b/src/components/structures/MessagePanel.js index 44bd521eb3..6f4a5460f6 100644 --- a/src/components/structures/MessagePanel.js +++ b/src/components/structures/MessagePanel.js @@ -266,7 +266,8 @@ module.exports = React.createClass({ // // we also need to figure out which is the last event we show which isn't // a local echo, to manage the read-marker. - var lastShownEventIndex = -1; + let lastShownEvent; + var lastShownNonLocalEchoIndex = -1; for (i = this.props.events.length-1; i >= 0; i--) { var mxEv = this.props.events[i]; @@ -274,8 +275,8 @@ module.exports = React.createClass({ continue; } - if (lastShownEventIndex < 0) { - lastShownEventIndex = i; + if (lastShownEvent === undefined) { + lastShownEvent = mxEv; } if (mxEv.status) { @@ -307,7 +308,7 @@ module.exports = React.createClass({ let mxEv = this.props.events[i]; let eventId = mxEv.getId(); let readMarkerInMels = false; - let last = (i === lastShownEventIndex); + let last = (mxEv === lastShownEvent); const wantTile = this._shouldShowEvent(mxEv); @@ -350,14 +351,14 @@ module.exports = React.createClass({ summarisedEvents.push(collapsedMxEv); } - // At this point, i = the index of the last event in the summary sequence + // At this point, i = the index of the last event in the summary sequence let eventTiles = summarisedEvents.map((e) => { // In order to prevent DateSeparators from appearing in the expanded form // of MemberEventListSummary, render each member event as if the previous // one was itself. This way, the timestamp of the previous event === the // timestamp of the current event, and no DateSeperator is inserted. - const ret = this._getTilesForEvent(e, e, last); + const ret = this._getTilesForEvent(e, e, e === lastShownEvent); prevEvent = e; return ret; }).reduce((a, b) => a.concat(b));