From b20c0f48e7098447c53d50bbd8f2091f5f212804 Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Sun, 24 Dec 2023 00:55:56 -0500 Subject: [PATCH 1/2] Firestore: local_serializer.ts: change toDbIndexState() arguments from user:User to uid:string --- packages/firestore/src/local/indexeddb_index_manager.ts | 8 ++++---- packages/firestore/src/local/local_serializer.ts | 4 ++-- .../firestore/test/unit/local/local_serializer.test.ts | 3 +-- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/packages/firestore/src/local/indexeddb_index_manager.ts b/packages/firestore/src/local/indexeddb_index_manager.ts index 33da3faa41d..04a380601b3 100644 --- a/packages/firestore/src/local/indexeddb_index_manager.ts +++ b/packages/firestore/src/local/indexeddb_index_manager.ts @@ -120,7 +120,7 @@ export class IndexedDbIndexManager implements IndexManager { */ private collectionParentsCache = new MemoryCollectionParentIndex(); - private uid: string; + private readonly uid: string; /** * Maps from a target to its equivalent list of sub-targets. Each sub-target @@ -131,7 +131,7 @@ export class IndexedDbIndexManager implements IndexManager { (l, r) => targetEquals(l, r) ); - constructor(private user: User, private readonly databaseId: DatabaseId) { + constructor(user: User, private readonly databaseId: DatabaseId) { this.uid = user.uid || ''; } @@ -210,7 +210,7 @@ export class IndexedDbIndexManager implements IndexManager { states.put( toDbIndexState( indexId, - this.user, + this.uid, index.indexState.sequenceNumber, index.indexState.offset ) @@ -754,7 +754,7 @@ export class IndexedDbIndexManager implements IndexManager { states.put( toDbIndexState( config.indexId!, - this.user, + this.uid, nextSequenceNumber, offset ) diff --git a/packages/firestore/src/local/local_serializer.ts b/packages/firestore/src/local/local_serializer.ts index e31f57ed9f2..dfd6ad5bc8d 100644 --- a/packages/firestore/src/local/local_serializer.ts +++ b/packages/firestore/src/local/local_serializer.ts @@ -476,13 +476,13 @@ export function fromDbIndexConfiguration( export function toDbIndexState( indexId: number, - user: User, + uid: string, sequenceNumber: number, offset: IndexOffset ): DbIndexState { return { indexId, - uid: user.uid || '', + uid, sequenceNumber, readTime: toDbTimestamp(offset.readTime), documentKey: encodeResourcePath(offset.documentKey.path), diff --git a/packages/firestore/test/unit/local/local_serializer.test.ts b/packages/firestore/test/unit/local/local_serializer.test.ts index 8631ebc48ec..ecb8b8548be 100644 --- a/packages/firestore/test/unit/local/local_serializer.test.ts +++ b/packages/firestore/test/unit/local/local_serializer.test.ts @@ -17,7 +17,6 @@ import { expect } from 'chai'; -import { User } from '../../../src/auth/user'; import { DatabaseId } from '../../../src/core/database_info'; import { encodeResourcePath } from '../../../src/local/encoded_resource_path'; import { DbMutationBatch } from '../../../src/local/indexeddb_schema'; @@ -258,7 +257,7 @@ describe('Local Serializer', () => { const dbIndexState = toDbIndexState( /* indexId= */ 1, - User.UNAUTHENTICATED, + /* uid= */ '', /* sequenceNumber= */ 2, expected ); From 1f9fdddf8d4869ec12509bba7333e2b0ac8096cc Mon Sep 17 00:00:00 2001 From: Denver Coneybeare Date: Sun, 24 Dec 2023 01:27:45 -0500 Subject: [PATCH 2/2] local_serializer.ts: remove unused import of User --- packages/firestore/src/local/local_serializer.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/firestore/src/local/local_serializer.ts b/packages/firestore/src/local/local_serializer.ts index dfd6ad5bc8d..b8916608711 100644 --- a/packages/firestore/src/local/local_serializer.ts +++ b/packages/firestore/src/local/local_serializer.ts @@ -16,7 +16,6 @@ */ import { Timestamp } from '../api/timestamp'; -import { User } from '../auth/user'; import { BundleMetadata, NamedQuery } from '../core/bundle'; import { LimitType, Query, queryWithLimit } from '../core/query'; import { SnapshotVersion } from '../core/snapshot_version';