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

Commit

Permalink
Merge pull request #3195 from matrix-org/bwindels/include-orig-in-his…
Browse files Browse the repository at this point in the history
…tory

Show original event in edit history
  • Loading branch information
bwindels authored Jul 11, 2019
2 parents 1c82266 + 11718a9 commit dd12824
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/components/views/dialogs/MessageEditHistoryDialog.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export default class MessageEditHistoryDialog extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
originalEvent: null,
error: null,
events: [],
nextBatch: null,
Expand Down Expand Up @@ -66,6 +67,7 @@ export default class MessageEditHistoryDialog extends React.PureComponent {
const newEvents = result.events;
this._locallyRedactEventsIfNeeded(newEvents);
this.setState({
originalEvent: this.state.originalEvent || result.originalEvent,
events: this.state.events.concat(newEvents),
nextBatch: result.nextBatch,
isLoading: false,
Expand Down Expand Up @@ -100,7 +102,12 @@ export default class MessageEditHistoryDialog extends React.PureComponent {
const DateSeparator = sdk.getComponent('messages.DateSeparator');
const nodes = [];
let lastEvent;
this.state.events.forEach(e => {
let allEvents = this.state.events;
// append original event when we've done last pagination
if (this.state.originalEvent && !this.state.nextBatch) {
allEvents = allEvents.concat(this.state.originalEvent);
}
allEvents.forEach(e => {
if (!lastEvent || wantsDateSeparator(lastEvent.getDate(), e.getDate())) {
nodes.push(<li key={e.getTs() + "~"}><DateSeparator ts={e.getTs()} /></li>);
}
Expand Down

0 comments on commit dd12824

Please sign in to comment.