@@ -59,7 +59,7 @@ const LOG_TAG = 'IndexedDbPersistence';
59
59
const CLIENT_METADATA_MAX_AGE_MS = 5000 ;
60
60
/**
61
61
* The maximum interval after which clients will update their metadata,
62
- * including refreshing the primary lease if held or potentially trying to
62
+ * including refreshing their primary lease if held or potentially trying to
63
63
* acquire it if not held.
64
64
*
65
65
* Primary clients may opportunistically refresh their metadata earlier
@@ -302,8 +302,8 @@ export class IndexedDbPersistence implements Persistence {
302
302
* Evaluate the state of all active instances and determine whether the local
303
303
* client is or can act as the holder of the primary lease. Returns whether
304
304
* the client is eligible for the lease, but does not actually acquire it.
305
- * May return 'false' even if there is no active leaseholder when a foreground
306
- * client should become leaseholder instead.
305
+ * May return 'false' even if there is no active leaseholder if another
306
+ * (foreground) client should become leaseholder instead.
307
307
*/
308
308
private canActAsPrimary (
309
309
currentPrimary : DbOwner | null ,
@@ -313,12 +313,12 @@ export class IndexedDbPersistence implements Persistence {
313
313
return PersistencePromise . resolve ( this . isLocalClient ( currentPrimary ) ) ;
314
314
}
315
315
316
- let canActAsPrimary = this . inForeground ;
317
-
318
316
// Check if this client is eligible for a primary lease based on its
319
317
// visibility state and the visibility state of all active clients. A
320
318
// client can obtain the primary lease if it is either in the foreground
321
319
// or if this client and all other clients are in the background.
320
+ let canActAsPrimary = this . inForeground ;
321
+
322
322
return PersistencePromise . resolve ( )
323
323
. next ( ( ) => {
324
324
if ( ! canActAsPrimary ) {
@@ -348,9 +348,7 @@ export class IndexedDbPersistence implements Persistence {
348
348
}
349
349
350
350
shutdown ( ) : Promise < void > {
351
- if ( ! this . started ) {
352
- return Promise . resolve ( ) ;
353
- }
351
+ assert ( this . started , 'IndexedDbPersistence shutdown without start!' ) ;
354
352
this . started = false ;
355
353
this . detachVisibilityHandler ( ) ;
356
354
this . detachWindowUnloadHook ( ) ;
0 commit comments