From f612b1933b92ef3ae58df12403a5c2536b8499a2 Mon Sep 17 00:00:00 2001
From: Michael Telatynski <7t3chguy@gmail.com>
Date: Thu, 14 Sep 2017 17:53:47 +0100
Subject: [PATCH] start MELS expanded if it contains a highlighted/permalinked
event.
Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
---
src/components/structures/MessagePanel.js | 21 +++++++++++--------
.../views/elements/MemberEventListSummary.js | 6 ++++--
2 files changed, 16 insertions(+), 11 deletions(-)
diff --git a/src/components/structures/MessagePanel.js b/src/components/structures/MessagePanel.js
index e5884973c6..103d386cd3 100644
--- a/src/components/structures/MessagePanel.js
+++ b/src/components/structures/MessagePanel.js
@@ -361,8 +361,13 @@ module.exports = React.createClass({
summarisedEvents.push(collapsedMxEv);
}
+ let highlightInMels = false;
+
// At this point, i = the index of the last event in the summary sequence
let eventTiles = summarisedEvents.map((e) => {
+ if (e.getId() === this.props.highlightedEventId) {
+ highlightInMels = true;
+ }
// 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
@@ -376,15 +381,13 @@ module.exports = React.createClass({
eventTiles = null;
}
- ret.push(
-
- {eventTiles}
-
- );
+ ret.push(
+ {eventTiles}
+ );
if (readMarkerInMels) {
ret.push(this._getReadMarkerTile(visible));
diff --git a/src/components/views/elements/MemberEventListSummary.js b/src/components/views/elements/MemberEventListSummary.js
index 842b44b793..689599da0b 100644
--- a/src/components/views/elements/MemberEventListSummary.js
+++ b/src/components/views/elements/MemberEventListSummary.js
@@ -34,11 +34,13 @@ module.exports = React.createClass({
threshold: React.PropTypes.number,
// Called when the MELS expansion is toggled
onToggle: React.PropTypes.func,
+ // Whether or not to begin with state.expanded=true
+ startExpanded: React.PropTypes.bool,
},
getInitialState: function() {
return {
- expanded: false,
+ expanded: Boolean(this.props.startExpanded),
};
},
@@ -376,7 +378,7 @@ module.exports = React.createClass({
return items[0];
} else if (remaining) {
items = items.slice(0, itemLimit);
- return (remaining > 1)
+ return (remaining > 1)
? _t("%(items)s and %(remaining)s others", { items: items.join(', '), remaining: remaining } )
: _t("%(items)s and one other", { items: items.join(', ') });
} else {