mirror of
https://github.com/vector-im/element-web.git
synced 2024-11-16 21:24:59 +08:00
Merge pull request #3195 from matrix-org/bwindels/include-orig-in-history
Show original event in edit history
This commit is contained in:
commit
dd12824a52
@ -30,6 +30,7 @@ export default class MessageEditHistoryDialog extends React.PureComponent {
|
|||||||
constructor(props) {
|
constructor(props) {
|
||||||
super(props);
|
super(props);
|
||||||
this.state = {
|
this.state = {
|
||||||
|
originalEvent: null,
|
||||||
error: null,
|
error: null,
|
||||||
events: [],
|
events: [],
|
||||||
nextBatch: null,
|
nextBatch: null,
|
||||||
@ -66,6 +67,7 @@ export default class MessageEditHistoryDialog extends React.PureComponent {
|
|||||||
const newEvents = result.events;
|
const newEvents = result.events;
|
||||||
this._locallyRedactEventsIfNeeded(newEvents);
|
this._locallyRedactEventsIfNeeded(newEvents);
|
||||||
this.setState({
|
this.setState({
|
||||||
|
originalEvent: this.state.originalEvent || result.originalEvent,
|
||||||
events: this.state.events.concat(newEvents),
|
events: this.state.events.concat(newEvents),
|
||||||
nextBatch: result.nextBatch,
|
nextBatch: result.nextBatch,
|
||||||
isLoading: false,
|
isLoading: false,
|
||||||
@ -100,7 +102,12 @@ export default class MessageEditHistoryDialog extends React.PureComponent {
|
|||||||
const DateSeparator = sdk.getComponent('messages.DateSeparator');
|
const DateSeparator = sdk.getComponent('messages.DateSeparator');
|
||||||
const nodes = [];
|
const nodes = [];
|
||||||
let lastEvent;
|
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())) {
|
if (!lastEvent || wantsDateSeparator(lastEvent.getDate(), e.getDate())) {
|
||||||
nodes.push(<li key={e.getTs() + "~"}><DateSeparator ts={e.getTs()} /></li>);
|
nodes.push(<li key={e.getTs() + "~"}><DateSeparator ts={e.getTs()} /></li>);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user