From b82280f7350482f753d77b40b816256bf4addfd1 Mon Sep 17 00:00:00 2001
From: James Calfee <james@jcalfee.info>
Date: Tue, 13 Sep 2016 17:36:22 -0500
Subject: [PATCH] Fixes 100% cpu when editing on some markdown posts (close
 #243)

---
 app/components/elements/ReplyEditor.jsx | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

diff --git a/app/components/elements/ReplyEditor.jsx b/app/components/elements/ReplyEditor.jsx
index 69572e368..7aed5c138 100644
--- a/app/components/elements/ReplyEditor.jsx
+++ b/app/components/elements/ReplyEditor.jsx
@@ -123,6 +123,7 @@ class ReplyEditor extends React.Component {
         const {setMetaData, formId, jsonMetadata} = this.props
         if(process.env.BROWSER) {
             let editorData = localStorage.getItem('replyEditorData-' + formId)
+            let rte_value = RichTextEditor.createEmptyValue();
             if(editorData) {
                 editorData = JSON.parse(editorData)
                 if(editorData.formId === formId) {
@@ -131,8 +132,10 @@ class ReplyEditor extends React.Component {
                     if(title) title.onChange(editorData.title)
                     if (editorData.body) {
                         body.onChange(editorData.body)
-                        const html = getHtml(editorData.body)
-                        this.state.rte_value = RichTextEditor.createValueFromString(html, 'html')
+                        // const html = getHtml(editorData.body)
+                        // console.log('createValueFromString mnt1', html);
+                        // this.state.rte_value = RichTextEditor.createValueFromString(html, 'html')
+                        // console.log('createValueFromString mnt1 done');
                     }
                 }
             }
@@ -144,7 +147,6 @@ class ReplyEditor extends React.Component {
                 if(isStory)
                     rte = JSON.parse(localStorage.getItem('replyEditorData-rte') || RTE_DEFAULT);
             }
-            let rte_value;
             if (RichTextEditor) {
                 if (body.value) {
                     if (isHtmlTest(body.value)) {
@@ -153,12 +155,10 @@ class ReplyEditor extends React.Component {
                         rte_value = RichTextEditor.createValueFromString(html, 'html')
                     } else {
                         rte = false;
-                        rte_value = RichTextEditor.createEmptyValue();
-                        // body.initialValue causes 100% cpu when editing http://localhost:3002/steemit/@cryptomental/can-a-viral-introduceyourself-post-be-engineered
+                        // console.log('createValueFromString mnt3');
                         // rte_value = RichTextEditor.createValueFromString(body.initialValue, 'html');
+                        // console.log('createValueFromString mnt3 done');
                     }
-                } else {
-                    rte_value = RichTextEditor.createEmptyValue();
                 }
             }
             this.setState({rte, rte_value})
-- 
GitLab