Skip to content

Commit c35a659

Browse files
Cleanup
1 parent 806a86a commit c35a659

File tree

3 files changed

+10
-12
lines changed

3 files changed

+10
-12
lines changed

packages/firestore/src/local/indexeddb_persistence.ts

+6-8
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ const LOG_TAG = 'IndexedDbPersistence';
5959
const CLIENT_METADATA_MAX_AGE_MS = 5000;
6060
/**
6161
* 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
6363
* acquire it if not held.
6464
*
6565
* Primary clients may opportunistically refresh their metadata earlier
@@ -302,8 +302,8 @@ export class IndexedDbPersistence implements Persistence {
302302
* Evaluate the state of all active instances and determine whether the local
303303
* client is or can act as the holder of the primary lease. Returns whether
304304
* 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.
307307
*/
308308
private canActAsPrimary(
309309
currentPrimary: DbOwner | null,
@@ -313,12 +313,12 @@ export class IndexedDbPersistence implements Persistence {
313313
return PersistencePromise.resolve(this.isLocalClient(currentPrimary));
314314
}
315315

316-
let canActAsPrimary = this.inForeground;
317-
318316
// Check if this client is eligible for a primary lease based on its
319317
// visibility state and the visibility state of all active clients. A
320318
// client can obtain the primary lease if it is either in the foreground
321319
// or if this client and all other clients are in the background.
320+
let canActAsPrimary = this.inForeground;
321+
322322
return PersistencePromise.resolve()
323323
.next(() => {
324324
if (!canActAsPrimary) {
@@ -348,9 +348,7 @@ export class IndexedDbPersistence implements Persistence {
348348
}
349349

350350
shutdown(): Promise<void> {
351-
if (!this.started) {
352-
return Promise.resolve();
353-
}
351+
assert(this.started, 'IndexedDbPersistence shutdown without start!');
354352
this.started = false;
355353
this.detachVisibilityHandler();
356354
this.detachWindowUnloadHook();

packages/firestore/src/local/indexeddb_schema.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -547,11 +547,11 @@ export class DbClientMetadata {
547547
static store = 'clientMetadata';
548548

549549
/** Keys are automatically assigned via the clientId properties. */
550-
static keyPath = ['clientId'];
550+
static keyPath = ['clientKey'];
551551

552552
constructor(
553553
/** The auto-generated client id assigned at client startup. */
554-
public clientId: string,
554+
public clientKey: string,
555555
/** The last time this state was updated. */
556556
public updateTimeMs: number,
557557
/** Whether this client is running in a foreground tab. */

packages/firestore/test/unit/specs/spec_test_runner.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -793,8 +793,8 @@ abstract class TestRunner {
793793
}
794794

795795
private async doAcquirePrimaryLease(): Promise<void> {
796-
// We drain the queue after running the client metadata refresh task as teh
797-
// refresh might schedule the primary state callback on the queue as well.
796+
// We drain the queue after running the client metadata refresh task as the
797+
// refresh might schedule a primary state callback on the queue as well.
798798
return this.queue
799799
.runDelayedOperationsEarly(TimerId.ClientMetadataRefresh)
800800
.then(() => this.queue.drain());

0 commit comments

Comments
 (0)