Delay the "Connection lost" message by a second
authorCarl Worth <cworth@cworth.org>
Sat, 6 Jun 2020 19:27:57 +0000 (12:27 -0700)
committerCarl Worth <cworth@cworth.org>
Sat, 6 Jun 2020 19:29:46 +0000 (12:29 -0700)
Otherwise, when simply clicking a link to navigate away from the page,
this scary-looking red box can appear. Nobody should complain if it
takes a few seconds for the game to notice a connection is lost.

scribe/scribe.jsx

index 81296dc900194121a76d1ce2a842803451ea33e4..06a8541297059bdc046f6f40ae3ac129d8ff2e74 100644 (file)
@@ -26,7 +26,9 @@ const events = new EventSource("events");
 
 events.onerror = function(event) {
   if (event.target.readyState === EventSource.CLOSED) {
+    setTimeout(() => {
       add_message("danger", "Connection to server lost.");
+    }, 1000);
   }
 };