Просмотр исходного кода

If no write operation has been performed, insert initial value.

Shun Miyazawa 1 год назад
Родитель
Сommit
7243c52f6e
1 измененных файлов с 3 добавлено и 4 удалено
  1. 3 4
      apps/app/src/server/service/yjs-connection-manager.ts

+ 3 - 4
apps/app/src/server/service/yjs-connection-manager.ts

@@ -59,10 +59,9 @@ class YjsConnectionManager {
 
     await this.mdb.flushDocument(pageId);
 
-    const persistedCodeMirrorText = persistedYdoc.getText('codemirror').toString();
-    const currentCodeMirrorText = currentYdoc.getText('codemirror').toString();
-
-    if (persistedCodeMirrorText === '' && currentCodeMirrorText === '') {
+    // If no write operation has been performed, insert initial value
+    const clientsSize = currentYdoc.store.clients.size;
+    if (clientsSize === 0) {
       currentYdoc.getText('codemirror').insert(0, initialValue);
     }