Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit f612b19

Browse files
committed
start MELS expanded if it contains a highlighted/permalinked event.
Signed-off-by: Michael Telatynski <[email protected]>
1 parent 94ec11d commit f612b19

File tree

2 files changed

+16
-11
lines changed

2 files changed

+16
-11
lines changed

src/components/structures/MessagePanel.js

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,13 @@ module.exports = React.createClass({
361361
summarisedEvents.push(collapsedMxEv);
362362
}
363363

364+
let highlightInMels = false;
365+
364366
// At this point, i = the index of the last event in the summary sequence
365367
let eventTiles = summarisedEvents.map((e) => {
368+
if (e.getId() === this.props.highlightedEventId) {
369+
highlightInMels = true;
370+
}
366371
// In order to prevent DateSeparators from appearing in the expanded form
367372
// of MemberEventListSummary, render each member event as if the previous
368373
// one was itself. This way, the timestamp of the previous event === the
@@ -376,15 +381,13 @@ module.exports = React.createClass({
376381
eventTiles = null;
377382
}
378383

379-
ret.push(
380-
<MemberEventListSummary
381-
key={key}
382-
events={summarisedEvents}
383-
onToggle={this._onWidgetLoad} // Update scroll state
384-
>
385-
{eventTiles}
386-
</MemberEventListSummary>
387-
);
384+
ret.push(<MemberEventListSummary key={key}
385+
events={summarisedEvents}
386+
onToggle={this._onWidgetLoad} // Update scroll state
387+
startExpanded={highlightInMels}
388+
>
389+
{eventTiles}
390+
</MemberEventListSummary>);
388391

389392
if (readMarkerInMels) {
390393
ret.push(this._getReadMarkerTile(visible));

src/components/views/elements/MemberEventListSummary.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,13 @@ module.exports = React.createClass({
3434
threshold: React.PropTypes.number,
3535
// Called when the MELS expansion is toggled
3636
onToggle: React.PropTypes.func,
37+
// Whether or not to begin with state.expanded=true
38+
startExpanded: React.PropTypes.bool,
3739
},
3840

3941
getInitialState: function() {
4042
return {
41-
expanded: false,
43+
expanded: Boolean(this.props.startExpanded),
4244
};
4345
},
4446

@@ -376,7 +378,7 @@ module.exports = React.createClass({
376378
return items[0];
377379
} else if (remaining) {
378380
items = items.slice(0, itemLimit);
379-
return (remaining > 1)
381+
return (remaining > 1)
380382
? _t("%(items)s and %(remaining)s others", { items: items.join(', '), remaining: remaining } )
381383
: _t("%(items)s and one other", { items: items.join(', ') });
382384
} else {

0 commit comments

Comments
 (0)