@@ -344,17 +344,17 @@ class SharedbAceBinding {
344
344
try {
345
345
this . cursorManager ?. removeCursor ( id ) ;
346
346
// eslint-disable-next-line no-empty
347
- } catch { }
347
+ } catch { }
348
348
349
349
try {
350
350
this . selectionManager ?. removeSelection ( id ) ;
351
351
// eslint-disable-next-line no-empty
352
- } catch { }
352
+ } catch { }
353
353
354
354
try {
355
355
this . radarManager ?. removeView ( id ) ;
356
356
// eslint-disable-next-line no-empty
357
- } catch { }
357
+ } catch { }
358
358
359
359
if ( id in this . connectedUsers ) {
360
360
delete this . connectedUsers [ id ] ;
@@ -363,7 +363,9 @@ class SharedbAceBinding {
363
363
return ;
364
364
}
365
365
366
- this . connectedUsers [ id ] = update . user ;
366
+ if ( ! this . connectedUsers [ id ] ) {
367
+ this . connectedUsers [ id ] = update . user ;
368
+ }
367
369
368
370
if ( this . cursorManager && update . cursorPos ) {
369
371
try {
@@ -464,6 +466,17 @@ class SharedbAceBinding {
464
466
*/
465
467
onRemoteReload = ( ) => {
466
468
this . logger . log ( '*remote*: reloading document' ) ;
469
+ // Destroy local presence if it exists to prevent
470
+ // submission of local presence again during initialization
471
+ if ( this . localPresence ) {
472
+ try {
473
+ this . logger . log ( '*remote*: destroying local presence' ) ;
474
+ this . localPresence . destroy ( ) ;
475
+ this . localPresence = undefined ;
476
+ } catch ( error ) {
477
+ console . warn ( "Error destroying local presence:" , error ) ;
478
+ }
479
+ }
467
480
this . setInitialValue ( ) ;
468
481
} ;
469
482
}
0 commit comments