Merge pull request #3195 from matrix-org/bwindels/include-orig-in-history

Show original event in edit history
pull/21833/head
Bruno Windels 2019-07-11 08:10:01 +00:00 committed by GitHub
commit dd12824a52
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 8 additions and 1 deletions

View File

@ -30,6 +30,7 @@ export default class MessageEditHistoryDialog extends React.PureComponent {
constructor(props) {
super(props);
this.state = {
originalEvent: null,
error: null,
events: [],
nextBatch: null,
@ -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,
@ -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>);
}