cancel pending edit when sending new edit
This commit is contained in:
parent
d0d327620b
commit
357ad3d50c
1 changed files with 10 additions and 0 deletions
|
@ -31,6 +31,7 @@ import {renderModel} from '../../../editor/render';
|
||||||
import EditorStateTransfer from '../../../utils/EditorStateTransfer';
|
import EditorStateTransfer from '../../../utils/EditorStateTransfer';
|
||||||
import {MatrixClient} from 'matrix-js-sdk';
|
import {MatrixClient} from 'matrix-js-sdk';
|
||||||
import classNames from 'classnames';
|
import classNames from 'classnames';
|
||||||
|
import {EventStatus} from 'matrix-js-sdk';
|
||||||
|
|
||||||
export default class MessageEditor extends React.Component {
|
export default class MessageEditor extends React.Component {
|
||||||
static propTypes = {
|
static propTypes = {
|
||||||
|
@ -195,12 +196,21 @@ export default class MessageEditor extends React.Component {
|
||||||
}, contentBody);
|
}, contentBody);
|
||||||
|
|
||||||
const roomId = this.props.editState.getEvent().getRoomId();
|
const roomId = this.props.editState.getEvent().getRoomId();
|
||||||
|
this._cancelPreviousPendingEdit();
|
||||||
this.context.matrixClient.sendMessage(roomId, content);
|
this.context.matrixClient.sendMessage(roomId, content);
|
||||||
|
|
||||||
dis.dispatch({action: "edit_event", event: null});
|
dis.dispatch({action: "edit_event", event: null});
|
||||||
dis.dispatch({action: 'focus_composer'});
|
dis.dispatch({action: 'focus_composer'});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_cancelPreviousPendingEdit() {
|
||||||
|
const originalEvent = this.props.editState.getEvent();
|
||||||
|
const previousEdit = originalEvent.replacingEvent();
|
||||||
|
if (previousEdit.status === EventStatus.QUEUED || previousEdit.status === EventStatus.NOT_SENT) {
|
||||||
|
this.context.matrixClient.cancelPendingEvent(previousEdit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
_onAutoCompleteConfirm = (completion) => {
|
_onAutoCompleteConfirm = (completion) => {
|
||||||
this.model.autoComplete.onComponentConfirm(completion);
|
this.model.autoComplete.onComponentConfirm(completion);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue