Skip to content

Commit a887823

Browse files
Fixing imports
1 parent 0b42fc1 commit a887823

File tree

3 files changed

+18
-22
lines changed

3 files changed

+18
-22
lines changed

packages/firestore/src/local/shared_client_state.ts

+12-16
Original file line numberDiff line numberDiff line change
@@ -21,13 +21,12 @@ import { debug, error } from '../util/log';
2121
import { primitiveComparator } from '../util/misc';
2222
import { SortedSet } from '../util/sorted_set';
2323
import { isSafeInteger } from '../util/types';
24-
import { forEach } from '../util/obj';
2524
import * as objUtils from '../util/obj';
2625

2726
const LOG_TAG = 'SharedClientState';
2827

29-
// The format of a the key for the client state in LocalStorage is:
30-
// fs_clients_<persistence_prefix>_<instance_key>
28+
// The format of the LocalStorage key storing the client state is:
29+
// fs_clients_<persistence_prefix>_<instance_key>
3130
const CLIENT_STATE_KEY_PREFIX = 'fs_clients';
3231

3332
/**
@@ -39,7 +38,7 @@ export type ClientKey = string;
3938
* The `SharedClientState` keeps track of the global state of the mutations
4039
* and query targets for all active clients with the same persistence key (i.e.
4140
* project ID and FirebaseApp name). It relays local changes to other clients
42-
* and updates its local state as new metadata is observed.
41+
* and updates its local state as new state is observed.
4342
*
4443
* `SharedClientState` is primarily used for synchronization in Multi-Tab
4544
* environments. Each tab is responsible for registering its active query
@@ -103,8 +102,8 @@ interface ClientStateSchema {
103102

104103
/**
105104
* Metadata state of a single client. Includes query targets, the minimum
106-
* pending and maximum pending mutation batch ID the last update time of this
107-
* state.
105+
* pending and maximum pending mutation batch ID, as well as the last update
106+
* time of this state.
108107
*/
109108
// Visible for testing.
110109
export interface ClientState {
@@ -115,9 +114,9 @@ export interface ClientState {
115114
}
116115

117116
/**
118-
* This class represents the immutable ClientState of clients read from
119-
* LocalStorage. It contains the list of all active query targets and the range
120-
* of the client's pending mutation batch IDs.
117+
* This class represents the immutable ClientState for a client read from
118+
* LocalStorage. It contains the list of its active query targets and the range
119+
* of its pending mutation batch IDs.
121120
*/
122121
class RemoteClientState implements ClientState {
123122
constructor(
@@ -129,7 +128,7 @@ class RemoteClientState implements ClientState {
129128
) {}
130129

131130
/**
132-
* Parses a ClientState from its JSON representation in LocalStorage.
131+
* Parses a ClientState from the JSON representation in LocalStorage.
133132
* Logs a warning and returns null if the data could not be parsed.
134133
*/
135134
static fromLocalStorageEntry(
@@ -258,7 +257,7 @@ export class LocalClientState implements ClientState {
258257
/**
259258
* `WebStorageSharedClientState` uses WebStorage (window.localStorage) as the
260259
* backing store for the SharedClientState. It keeps track of all active
261-
* clients and supports modification of the current client's data.
260+
* clients and supports modifications of the current client's data.
262261
*/
263262
export class WebStorageSharedClientState implements SharedClientState {
264263
private readonly storage: Storage;
@@ -322,11 +321,9 @@ export class WebStorageSharedClientState implements SharedClientState {
322321

323322
getAllActiveQueryTargets(): SortedSet<TargetId> {
324323
let activeTargets = new SortedSet<TargetId>(primitiveComparator);
325-
326324
objUtils.forEach(this.activeClients, (key, value) => {
327325
activeTargets = activeTargets.unionWith(value.activeTargetIds);
328326
});
329-
330327
return activeTargets;
331328
}
332329

@@ -371,7 +368,6 @@ export class WebStorageSharedClientState implements SharedClientState {
371368
event.key !== this.storageKey,
372369
'Received LocalStorage notification for local change.'
373370
);
374-
console.log(event.newValue);
375371
const clientKey = this.fromLocalStorageClientKey(event.key);
376372
if (clientKey) {
377373
if (event.newValue == null) {
@@ -395,7 +391,7 @@ export class WebStorageSharedClientState implements SharedClientState {
395391

396392
private persistState(): void {
397393
// TODO(multitab): Consider rate limiting/combining state updates for
398-
// clients that frequently change update client state.
394+
// clients that frequently update their client state.
399395
assert(this.started, 'WebStorageSharedClientState used before started.');
400396
debug(LOG_TAG, 'Persisting state in LocalStorage');
401397
this.localClientState.refreshLastUpdateTime();
@@ -405,7 +401,7 @@ export class WebStorageSharedClientState implements SharedClientState {
405401
);
406402
}
407403

408-
/** Assembles the key for client states in LocalStorage */
404+
/** Assembles the key for a client state in LocalStorage */
409405
private toLocalStorageClientKey(clientKey: string): string {
410406
assert(
411407
clientKey.indexOf('_') === -1,

packages/firestore/test/unit/local/persistence_test_helpers.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export async function testMemoryPersistence(): Promise<MemoryPersistence> {
6262

6363
/**
6464
* Creates and starts a WebStorageSharedClientState instance for testing,
65-
* destroying any previous contents if they existed.
65+
* destroying any previous contents in LocalStorage if they existed.
6666
*/
6767
export async function testWebStorageSharedClientState(
6868
instanceKey: string,

packages/firestore/test/unit/local/web_storage_synchronized_client_state.test.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,9 @@ import { AutoId } from '../../../src/util/misc';
2525
import { expect } from 'chai';
2626

2727
/**
28-
* The test asserts that update time of each row in LocalStorage. We allow a
29-
* 0.1s difference in update time and local time to account for processing and
30-
* locking in LocalStorage.
28+
* The test asserts that the lastUpdateTime of each row in LocalStorage gets
29+
* updated. We allow a 0.1s difference in update time to account for processing
30+
* and locking time in LocalStorage.
3131
*/
3232
const GRACE_INTERVAL_MS = 100;
3333

@@ -195,7 +195,7 @@ describe('WebStorageSharedClientState', () => {
195195
sharedClientState.addLocalQueryTarget(4);
196196
verifyState(1, [3, 4]);
197197

198-
// This is technically invalid as ID of the minimum mutation batch should
198+
// This is technically invalid as IDs of minimum mutation batches should
199199
// never decrease over the lifetime of a client, but we use it here to
200200
// test the underlying logic that extracts the mutation batch IDs.
201201
sharedClientState.addLocalPendingMutation(0);
@@ -207,7 +207,7 @@ describe('WebStorageSharedClientState', () => {
207207
verifyState(1, [3, 4]);
208208
});
209209

210-
it.only('with data from new clients', () => {
210+
it('with data from new clients', () => {
211211
const secondaryClientKey = `fs_clients_${
212212
persistenceHelpers.TEST_PERSISTENCE_PREFIX
213213
}_${AutoId.newId()}`;

0 commit comments

Comments
 (0)