Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit f264075

Browse files
committed
null-guard history properly
Signed-off-by: Michael Telatynski <[email protected]>
1 parent 265e426 commit f264075

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/components/views/rooms/MessageComposerInput.js

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1255,16 +1255,14 @@ export default class MessageComposerInput extends React.Component {
12551255

12561256
let editorState;
12571257
const historyItem = this.historyManager.getItem(delta);
1258-
if (historyItem) {
1259-
if (historyItem.format === 'rich' && !this.state.isRichTextEnabled) {
1260-
editorState = this.richToMdEditorState(historyItem.value);
1261-
}
1262-
else if (historyItem.format === 'markdown' && this.state.isRichTextEnabled) {
1263-
editorState = this.mdToRichEditorState(historyItem.value);
1264-
}
1265-
else {
1266-
editorState = historyItem.value;
1267-
}
1258+
if (!historyItem) return;
1259+
1260+
if (historyItem.format === 'rich' && !this.state.isRichTextEnabled) {
1261+
editorState = this.richToMdEditorState(historyItem.value);
1262+
} else if (historyItem.format === 'markdown' && this.state.isRichTextEnabled) {
1263+
editorState = this.mdToRichEditorState(historyItem.value);
1264+
} else {
1265+
editorState = historyItem.value;
12681266
}
12691267

12701268
// Move selection to the end of the selected history

0 commit comments

Comments
 (0)