Skip to content

Commit 7b318b4

Browse files
Merge branch 'firestore-multi-tab' of https://github.com/firebase/firebase-js-sdk into firestore-multi-tab
2 parents 26af01c + 12a0936 commit 7b318b4

File tree

3 files changed

+21
-20
lines changed

3 files changed

+21
-20
lines changed

packages/firestore/src/local/shared_client_state.ts

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,26 +38,25 @@ import { batchIdSet, TargetIdSet, targetIdSet } from '../model/collections';
3838

3939
const LOG_TAG = 'SharedClientState';
4040

41-
// TODO(multitab): Change prefix of keys to "firestore_" to match IndexedDb.
42-
4341
// The format of the LocalStorage key that stores the client state is:
44-
// fs_clients_<persistence_prefix>_<instance_key>
45-
const CLIENT_STATE_KEY_PREFIX = 'fs_clients';
42+
// firestore_clients_<persistence_prefix>_<instance_key>
43+
const CLIENT_STATE_KEY_PREFIX = 'firestore_clients';
4644

4745
// The format of the LocalStorage key that stores the mutation state is:
48-
// fs_mutations_<persistence_prefix>_<batch_id> (for unauthenticated users)
49-
// or: fs_mutations_<persistence_prefix>_<batch_id>_<user_uid>
46+
// firestore_mutations_<persistence_prefix>_<batch_id>
47+
// (for unauthenticated users)
48+
// or: firestore_mutations_<persistence_prefix>_<batch_id>_<user_uid>
5049
//
5150
// 'user_uid' is last to avoid needing to escape '_' characters that it might
5251
// contain.
53-
const MUTATION_BATCH_KEY_PREFIX = 'fs_mutations';
52+
const MUTATION_BATCH_KEY_PREFIX = 'firestore_mutations';
5453

5554
// The format of the LocalStorage key that stores a query target's metadata is:
56-
// fs_targets_<persistence_prefix>_<target_id>
57-
const QUERY_TARGET_KEY_PREFIX = 'fs_targets';
55+
// firestore_targets_<persistence_prefix>_<target_id>
56+
const QUERY_TARGET_KEY_PREFIX = 'firestore_targets';
5857

5958
// The LocalStorage key that stores the primary tab's online state.
60-
const ONLINE_STATE_KEY = 'fs_online_state';
59+
const ONLINE_STATE_KEY = 'firestore_online_state';
6160

6261
/**
6362
* A randomly-generated key assigned to each Firestore instance at startup.

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ export const TEST_PERSISTENCE_PREFIX =
4545
'firestore/[DEFAULT]/PersistenceTestHelpers';
4646

4747
/** The prefix used by the keys that Firestore writes to Local Storage. */
48-
const LOCAL_STORAGE_PREFIX = 'fs_';
48+
const LOCAL_STORAGE_PREFIX = 'firestore_';
4949

5050
/**
5151
* Creates and starts an IndexedDbPersistence instance for testing, destroying

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

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,22 +61,24 @@ const TEST_ERROR = new FirestoreError('internal', 'Test Error');
6161

6262
function mutationKey(user: User, batchId: BatchId): string {
6363
if (user.isAuthenticated()) {
64-
return `fs_mutations_${
64+
return `firestore_mutations_${
6565
persistenceHelpers.TEST_PERSISTENCE_PREFIX
6666
}_${batchId}_${user.uid}`;
6767
} else {
68-
return `fs_mutations_${
68+
return `firestore_mutations_${
6969
persistenceHelpers.TEST_PERSISTENCE_PREFIX
7070
}_${batchId}`;
7171
}
7272
}
7373

7474
function targetKey(targetId: TargetId): string {
75-
return `fs_targets_${persistenceHelpers.TEST_PERSISTENCE_PREFIX}_${targetId}`;
75+
return `firestore_targets_${
76+
persistenceHelpers.TEST_PERSISTENCE_PREFIX
77+
}_${targetId}`;
7678
}
7779

7880
function onlineStateKey(): string {
79-
return 'fs_online_state';
81+
return 'firestore_online_state';
8082
}
8183

8284
interface TestSharedClientState {
@@ -227,7 +229,7 @@ describe('WebStorageSharedClientState', () => {
227229
): void {
228230
const actual = JSON.parse(
229231
localStorage.getItem(
230-
`fs_clients_${
232+
`firestore_clients_${
231233
persistenceHelpers.TEST_PERSISTENCE_PREFIX
232234
}_${primaryClientId}`
233235
)
@@ -405,7 +407,7 @@ describe('WebStorageSharedClientState', () => {
405407

406408
describe('combines client state', () => {
407409
const secondaryClientId = AutoId.newId();
408-
const secondaryClientStateKey = `fs_clients_${
410+
const secondaryClientStateKey = `firestore_clients_${
409411
persistenceHelpers.TEST_PERSISTENCE_PREFIX
410412
}_${secondaryClientId}`;
411413

@@ -578,7 +580,7 @@ describe('WebStorageSharedClientState', () => {
578580
});
579581

580582
it('ignores invalid data', async () => {
581-
const secondaryClientStateKey = `fs_clients_${
583+
const secondaryClientStateKey = `firestore_clients_${
582584
persistenceHelpers.TEST_PERSISTENCE_PREFIX
583585
}_${AutoId.newId()}`;
584586

@@ -725,10 +727,10 @@ describe('WebStorageSharedClientState', () => {
725727
const firstClientTargetId: TargetId = 1;
726728
const secondClientTargetId: TargetId = 2;
727729

728-
const firstClientStorageKey = `fs_clients_${
730+
const firstClientStorageKey = `firestore_clients_${
729731
persistenceHelpers.TEST_PERSISTENCE_PREFIX
730732
}_${AutoId.newId()}`;
731-
const secondClientStorageKey = `fs_clients_${
733+
const secondClientStorageKey = `firestore_clients_${
732734
persistenceHelpers.TEST_PERSISTENCE_PREFIX
733735
}_${AutoId.newId()}`;
734736

0 commit comments

Comments
 (0)