ryoji-s 2 лет назад
Родитель
Сommit
1d19d71c11
1 измененных файлов с 21 добавлено и 17 удалено
  1. 21 17
      packages/editor/src/components/CodeMirrorEditorMain.tsx

+ 21 - 17
packages/editor/src/components/CodeMirrorEditorMain.tsx

@@ -46,7 +46,7 @@ export const CodeMirrorEditorMain = (props: Props): JSX.Element => {
   const [ydoc, setYdoc] = useState<Y.Doc | null>(null);
   const [provider, setProvider] = useState<SocketIOProvider | null>(null);
   const [cPageId, setCPageId] = useState(pageId);
-  const [isGlobalSync, setIsGlobalSync] = useState<boolean>(false);
+  // const [isGlobalSync, setIsGlobalSync] = useState<boolean>(false);
 
   // cleanup ydoc and socketIOProvider
   useEffect(() => {
@@ -69,7 +69,7 @@ export const CodeMirrorEditorMain = (props: Props): JSX.Element => {
 
     setCPageId(pageId);
 
-    setIsGlobalSync(false);
+    // setIsGlobalSync(false);
   }, [cPageId, pageId, provider, socket, ydoc]);
 
   // setup ydoc
@@ -105,11 +105,9 @@ export const CodeMirrorEditorMain = (props: Props): JSX.Element => {
       if (isSync) {
         // TODO: use SocketEventName
         socket.emit('ydoc:sync', { pageId, initialValue });
-        socket.on('status', () => {
-          console.log('socket');
-        });
+
       }
-      setIsGlobalSync(isSync);
+      // setIsGlobalSync(isSync);
     });
 
     // TODO: delete this code
@@ -189,16 +187,22 @@ export const CodeMirrorEditorMain = (props: Props): JSX.Element => {
   }, [codeMirrorEditor, onSave]);
 
   return (
-    <>
-      {isGlobalSync
-        ? (
-          <CodeMirrorEditor
-            editorKey={GlobalCodeMirrorEditorKey.MAIN}
-            onChange={onChange}
-            onUpload={onUpload}
-            indentSize={indentSize}
-          />
-        ) : <p className="text-danger font-weight-bold">connecting ...</p>}
-    </>
+    <CodeMirrorEditor
+      editorKey={GlobalCodeMirrorEditorKey.MAIN}
+      onChange={onChange}
+      onUpload={onUpload}
+      indentSize={indentSize}
+    />
+    // <>
+    //   {isGlobalSync
+    //     ? (
+    //       <CodeMirrorEditor
+    //         editorKey={GlobalCodeMirrorEditorKey.MAIN}
+    //         onChange={onChange}
+    //         onUpload={onUpload}
+    //         indentSize={indentSize}
+    //       />
+    //     ) : <p className="text-danger font-weight-bold">connecting ...</p>}
+    // </>
   );
 };