@@ -69,6 +69,8 @@ export class CodeSandboxOTClient extends OTClient {
6969 if ( this . lastAcknowledgedRevision < revision ) {
7070 this . lastAcknowledgedRevision = revision ;
7171 this . serverAck ( ) ;
72+ } else {
73+ this . resetAwaitSynchronized ( ) ;
7274 }
7375 } )
7476 . catch ( error => {
@@ -87,16 +89,20 @@ export class CodeSandboxOTClient extends OTClient {
8789 this . onApplyOperation ( operation ) ;
8890 }
8991
92+ resetAwaitSynchronized ( ) {
93+ // If we are back in synchronized state we resolve the blocker
94+ if ( this . state === synchronized_ && this . awaitSynchronized ) {
95+ const awaitSynchronized = this . awaitSynchronized ;
96+ this . awaitSynchronized = null ;
97+ awaitSynchronized . resolve ( ) ;
98+ }
99+ }
100+
90101 serverAck ( ) {
91102 try {
92103 super . serverAck ( ) ;
93104
94- // If we are back in synchronized state we resolve the blocker
95- if ( this . state === synchronized_ && this . awaitSynchronized ) {
96- const awaitSynchronized = this . awaitSynchronized ;
97- this . awaitSynchronized = null ;
98- awaitSynchronized . resolve ( ) ;
99- }
105+ this . resetAwaitSynchronized ( ) ;
100106 } catch ( e ) {
101107 // Undo the revision increment again
102108 super . revision -- ;
@@ -148,7 +154,7 @@ export default (
148154 } ,
149155 create ( moduleShortid , initialRevision ) {
150156 const client = new CodeSandboxOTClient (
151- initialRevision ,
157+ initialRevision || 0 ,
152158 moduleShortid ,
153159 ( revision , operation ) =>
154160 sendOperation ( moduleShortid , revision , operation ) ,
0 commit comments