From f5c477bbc8b702729ba9938928e12eb9ac95d92a Mon Sep 17 00:00:00 2001 From: "J. Ryan Stinnett" Date: Fri, 22 Feb 2019 15:48:36 +0000 Subject: [PATCH] Remove duplicated conversion from `enableRichText` `enableRichText` would convert the editor state between rich and md versions explicitly, but then it would also call `createEditorState`, which can do the same thing. This removes the duplication, and also supplies the right arguments to `createEditorState` so it can do its work correctly. --- src/components/views/rooms/MessageComposerInput.js | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/components/views/rooms/MessageComposerInput.js b/src/components/views/rooms/MessageComposerInput.js index 1954ca0d84..08e5de3477 100644 --- a/src/components/views/rooms/MessageComposerInput.js +++ b/src/components/views/rooms/MessageComposerInput.js @@ -686,17 +686,14 @@ export default class MessageComposerInput extends React.Component { enableRichtext(enabled: boolean) { if (enabled === this.state.isRichTextEnabled) return; - let editorState = null; - if (enabled) { - editorState = this.mdToRichEditorState(this.state.editorState); - } else { - editorState = this.richToMdEditorState(this.state.editorState); - } - Analytics.setRichtextMode(enabled); this.setState({ - editorState: this.createEditorState(enabled, editorState), + editorState: this.createEditorState( + enabled, + this.state.editorState, + this.state.isRichTextEnabled, + ), isRichTextEnabled: enabled, }, ()=>{ this._editor.focus();