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

Commit b06d540

Browse files
authored
Merge pull request #1388 from matrix-org/t3chguy/start_mels_expanded
start MELS expanded if it contains a highlighted/permalinked event.
2 parents 6a53b7b + f612b19 commit b06d540

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
@@ -365,8 +365,13 @@ module.exports = React.createClass({
365365
summarisedEvents.push(collapsedMxEv);
366366
}
367367

368+
let highlightInMels = false;
369+
368370
// At this point, i = the index of the last event in the summary sequence
369371
let eventTiles = summarisedEvents.map((e) => {
372+
if (e.getId() === this.props.highlightedEventId) {
373+
highlightInMels = true;
374+
}
370375
// In order to prevent DateSeparators from appearing in the expanded form
371376
// of MemberEventListSummary, render each member event as if the previous
372377
// one was itself. This way, the timestamp of the previous event === the
@@ -380,15 +385,13 @@ module.exports = React.createClass({
380385
eventTiles = null;
381386
}
382387

383-
ret.push(
384-
<MemberEventListSummary
385-
key={key}
386-
events={summarisedEvents}
387-
onToggle={this._onWidgetLoad} // Update scroll state
388-
>
389-
{eventTiles}
390-
</MemberEventListSummary>
391-
);
388+
ret.push(<MemberEventListSummary key={key}
389+
events={summarisedEvents}
390+
onToggle={this._onWidgetLoad} // Update scroll state
391+
startExpanded={highlightInMels}
392+
>
393+
{eventTiles}
394+
</MemberEventListSummary>);
392395

393396
if (readMarkerInMels) {
394397
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)