@@ -209,10 +209,11 @@ export class FirestoreClient {
209
209
/** Enables the network connection and requeues all pending operations. */
210
210
enableNetwork ( ) : Promise < void > {
211
211
this . verifyNotTerminated ( ) ;
212
- return enqueueEnableNetwork (
212
+ return enqueueNetworkEnabled (
213
213
this . asyncQueue ,
214
214
this . remoteStore ,
215
- this . persistence
215
+ this . persistence ,
216
+ /* enabled= */ true
216
217
) ;
217
218
}
218
219
@@ -353,10 +354,11 @@ export class FirestoreClient {
353
354
/** Disables the network connection. Pending operations will not complete. */
354
355
disableNetwork ( ) : Promise < void > {
355
356
this . verifyNotTerminated ( ) ;
356
- return enqueueDisableNetwork (
357
+ return enqueueNetworkEnabled (
357
358
this . asyncQueue ,
358
359
this . remoteStore ,
359
- this . persistence
360
+ this . persistence ,
361
+ /* enabled= */ false
360
362
) ;
361
363
}
362
364
@@ -461,35 +463,18 @@ export function enqueueWrite(
461
463
return deferred . promise ;
462
464
}
463
465
464
- /** Enables the network connection and requeues all pending operations. */
465
- export function enqueueEnableNetwork (
466
+ export function enqueueNetworkEnabled (
466
467
asyncQueue : AsyncQueue ,
467
468
remoteStore : RemoteStore ,
468
- persistence : Persistence
469
+ persistence : Persistence ,
470
+ enabled : boolean
469
471
) : Promise < void > {
470
472
return asyncQueue . enqueue ( ( ) => {
471
473
persistence . setNetworkEnabled ( true ) ;
472
- return remoteStore . enableNetwork ( ) ;
474
+ return enabled ? remoteStore . enableNetwork ( ) : remoteStore . disableNetwork ( ) ;
473
475
} ) ;
474
476
}
475
477
476
- /** Disables the network connection. Pending operations will not complete. */
477
- export function enqueueDisableNetwork (
478
- asyncQueue : AsyncQueue ,
479
- remoteStore : RemoteStore ,
480
- persistence : Persistence
481
- ) : Promise < void > {
482
- return asyncQueue . enqueue ( ( ) => {
483
- persistence . setNetworkEnabled ( false ) ;
484
- return remoteStore . disableNetwork ( ) ;
485
- } ) ;
486
- }
487
-
488
- /**
489
- * Returns a Promise that resolves when all writes that were pending at the time this
490
- * method was called received server acknowledgement. An acknowledgement can be either acceptance
491
- * or rejection.
492
- */
493
478
export function enqueueWaitForPendingWrites (
494
479
asyncQueue : AsyncQueue ,
495
480
syncEngine : SyncEngine
@@ -517,7 +502,6 @@ export function enqueueListen(
517
502
} ;
518
503
}
519
504
520
- /** Registers the listener for onSnapshotsInSync() */
521
505
export function enqueueSnapshotsInSyncListen (
522
506
asyncQueue : AsyncQueue ,
523
507
eventManager : EventManager ,
0 commit comments