@@ -243,9 +243,9 @@ export class ClientGameRunner {
243243 "" ,
244244 this . lobby . gameID ,
245245 this . lobby . clientID ,
246+ true ,
247+ "You are desynced from other players. What you see might differ from other players." ,
246248 ) ;
247- this . stop ( ) ;
248- return ;
249249 }
250250 if ( message . type == "turn" ) {
251251 if ( ! this . hasJoined ) {
@@ -320,12 +320,17 @@ function showErrorModal(
320320 stack : string ,
321321 gameID : GameID ,
322322 clientID : ClientID ,
323+ closable = false ,
324+ heading = "Game crashed!" ,
323325) {
324326 const errorText = `Error: ${ errMsg } \nStack: ${ stack } ` ;
325- consolex . error ( errorText ) ;
327+
328+ if ( document . querySelector ( "#error-modal" ) ) {
329+ return ;
330+ }
326331
327332 const modal = document . createElement ( "div" ) ;
328- const content = `Game crashed! game id: ${ gameID } , client id: ${ clientID } \nPlease paste the following in your bug report in Discord:\n${ errorText } ` ;
333+ const content = `${ heading } \n game id: ${ gameID } , client id: ${ clientID } \nPlease paste the following in your bug report in Discord:\n${ errorText } ` ;
329334
330335 // Create elements
331336 const pre = document . createElement ( "pre" ) ;
@@ -342,11 +347,23 @@ function showErrorModal(
342347 . catch ( ( ) => ( button . textContent = "Failed to copy" ) ) ;
343348 } ) ;
344349
350+ const closeButton = document . createElement ( "button" ) ;
351+ closeButton . textContent = "X" ;
352+ closeButton . style . cssText =
353+ "color: white;top: 0px;right: 0px;cursor: pointer;background: red;margin-right: 0px;position: fixed;width: 40px;" ;
354+ closeButton . addEventListener ( "click" , ( ) => {
355+ modal . style . display = "none" ;
356+ } ) ;
357+
345358 // Add to modal
346359 modal . style . cssText =
347360 "position:fixed; padding:20px; background:white; border:1px solid black; top:50%; left:50%; transform:translate(-50%,-50%); z-index:9999;" ;
348361 modal . appendChild ( pre ) ;
349362 modal . appendChild ( button ) ;
363+ modal . id = "error-modal" ;
364+ if ( closable ) {
365+ modal . appendChild ( closeButton ) ;
366+ }
350367
351368 document . body . appendChild ( modal ) ;
352369}
0 commit comments