Fix multiple timeline panels handling composer and edit events

This commit is contained in:
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,6 +448,7 @@ class TimelinePanel extends React.Component {
break; break;
case "edit_event": { case "edit_event": {
if (this.props.manageComposerDispatches) {
const editState = payload.event ? new EditorStateTransfer(payload.event) : null; const editState = payload.event ? new EditorStateTransfer(payload.event) : null;
this.setState({editState}, () => { this.setState({editState}, () => {
if (payload.event && this._messagePanel.current) { if (payload.event && this._messagePanel.current) {
@ -454,10 +457,12 @@ class TimelinePanel extends React.Component {
); );
} }
}); });
}
break; break;
} }
case Action.ComposerInsert: { case Action.ComposerInsert: {
if (this.props.manageComposerDispatches) {
// re-dispatch to the correct composer // re-dispatch to the correct composer
if (this.state.editState) { if (this.state.editState) {
dis.dispatch({ dis.dispatch({
@ -470,6 +475,7 @@ class TimelinePanel extends React.Component {
action: "send_composer_insert", action: "send_composer_insert",
}); });
} }
}
break; break;
} }