Fix multiple timeline panels handling composer and edit events

pull/21833/head
Michael Telatynski 2021-06-28 15:56:37 +01:00
parent 53a6089cc9
commit 83af38a85f
2 changed files with 26 additions and 19 deletions

View File

@ -2025,6 +2025,7 @@ export default class RoomView extends React.Component<IProps, IState> {
manageReadReceipts={!this.state.isPeeking} manageReadReceipts={!this.state.isPeeking}
sendReadReceiptOnLoad={!this.state.wasContextSwitch} sendReadReceiptOnLoad={!this.state.wasContextSwitch}
manageReadMarkers={!this.state.isPeeking} manageReadMarkers={!this.state.isPeeking}
manageComposerDispatches={true}
hidden={hideMessagePanel} hidden={hideMessagePanel}
highlightedEventId={highlightedEventId} highlightedEventId={highlightedEventId}
eventId={this.state.initialEventId} eventId={this.state.initialEventId}

View File

@ -72,6 +72,8 @@ class TimelinePanel extends React.Component {
manageReadReceipts: PropTypes.bool, manageReadReceipts: PropTypes.bool,
sendReadReceiptOnLoad: PropTypes.bool, sendReadReceiptOnLoad: PropTypes.bool,
manageReadMarkers: PropTypes.bool, manageReadMarkers: PropTypes.bool,
// with this enabled it'll listen and react to Action.ComposerInsert and `edit_event`
manageComposerDispatches: PropTypes.bool,
// true to give the component a 'display: none' style. // true to give the component a 'display: none' style.
hidden: PropTypes.bool, hidden: PropTypes.bool,
@ -446,29 +448,33 @@ class TimelinePanel extends React.Component {
break; break;
case "edit_event": { case "edit_event": {
const editState = payload.event ? new EditorStateTransfer(payload.event) : null; if (this.props.manageComposerDispatches) {
this.setState({editState}, () => { const editState = payload.event ? new EditorStateTransfer(payload.event) : null;
if (payload.event && this._messagePanel.current) { this.setState({editState}, () => {
this._messagePanel.current.scrollToEventIfNeeded( if (payload.event && this._messagePanel.current) {
payload.event.getId(), this._messagePanel.current.scrollToEventIfNeeded(
); payload.event.getId(),
} );
}); }
});
}
break; break;
} }
case Action.ComposerInsert: { case Action.ComposerInsert: {
// re-dispatch to the correct composer if (this.props.manageComposerDispatches) {
if (this.state.editState) { // re-dispatch to the correct composer
dis.dispatch({ if (this.state.editState) {
...payload, dis.dispatch({
action: "edit_composer_insert", ...payload,
}); action: "edit_composer_insert",
} else { });
dis.dispatch({ } else {
...payload, dis.dispatch({
action: "send_composer_insert", ...payload,
}); action: "send_composer_insert",
});
}
} }
break; break;
} }