diff web/SyncedGraph.ts @ 2421:ac55319a2eac

don't drop patches that arrive before we get WS connected
author drewp@bigasterisk.com
date Tue, 21 May 2024 16:10:39 -0700
parents 4556eebe5d73
children d1f86109e3cc
line wrap: on
line diff
--- a/web/SyncedGraph.ts	Tue May 21 14:50:01 2024 -0700
+++ b/web/SyncedGraph.ts	Tue May 21 16:10:39 2024 -0700
@@ -151,22 +151,19 @@
   }
 
   applyAndSendPatch(patch: Patch) {
-    console.time("applyAndSendPatch");
     if (!this.client) {
-      log("not connected-- dropping patch");
+      throw new Error("no client yet");
+    }
+    if (patch.isEmpty()) {
       return;
     }
-    if (!patch.isEmpty()) {
-      this._applyPatch(patch);
-      // // chaos delay
-      //       setTimeout(()=>{
-      if (this.client) {
-        log("sending patch:\n", patch.dump());
-        this.client.sendPatch(patch);
-      }
-      // },300*Math.random())
-    }
-    console.timeEnd("applyAndSendPatch");
+    this._applyPatch(patch);
+    // // chaos delay
+    //       setTimeout(()=>{
+    log("sending patch:\n", patch.dump());
+    this.client.sendPatch(patch);
+
+    // },300*Math.random())
   }
 
   _applyPatch(patch: Patch) {