null-guard history properly

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski 2018-07-26 17:11:32 +01:00
parent 265e4267b8
commit f264075369
No known key found for this signature in database
GPG key ID: 3F879DA5AD802A5E

View file

@ -1255,17 +1255,15 @@ export default class MessageComposerInput extends React.Component {
let editorState; let editorState;
const historyItem = this.historyManager.getItem(delta); const historyItem = this.historyManager.getItem(delta);
if (historyItem) { if (!historyItem) return;
if (historyItem.format === 'rich' && !this.state.isRichTextEnabled) { if (historyItem.format === 'rich' && !this.state.isRichTextEnabled) {
editorState = this.richToMdEditorState(historyItem.value); editorState = this.richToMdEditorState(historyItem.value);
} } else if (historyItem.format === 'markdown' && this.state.isRichTextEnabled) {
else if (historyItem.format === 'markdown' && this.state.isRichTextEnabled) {
editorState = this.mdToRichEditorState(historyItem.value); editorState = this.mdToRichEditorState(historyItem.value);
} } else {
else {
editorState = historyItem.value; editorState = historyItem.value;
} }
}
// Move selection to the end of the selected history // Move selection to the end of the selected history
const change = editorState.change().collapseToEndOf(editorState.document); const change = editorState.change().collapseToEndOf(editorState.document);