Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Firestore: local_serializer.ts: change toDbIndexState() argument from user:User to uid:string #7909

Merged
merged 2 commits into from
Jan 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions packages/firestore/src/local/indexeddb_index_manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -131,7 +131,7 @@ export class IndexedDbIndexManager implements IndexManager {
(l, r) => targetEquals(l, r)
);

constructor(private user: User, private readonly databaseId: DatabaseId) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you share with me why private is removed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's because the User argument is no longer stored in a property; instead, its "uid" is stored. Therefore, removing the private makes it no longer a property on the object but rather just an argument to the constructor.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

constructor(user: User, private readonly databaseId: DatabaseId) {
this.uid = user.uid || '';
}

Expand Down Expand Up @@ -210,7 +210,7 @@ export class IndexedDbIndexManager implements IndexManager {
states.put(
toDbIndexState(
indexId,
this.user,
this.uid,
index.indexState.sequenceNumber,
index.indexState.offset
)
Expand Down Expand Up @@ -754,7 +754,7 @@ export class IndexedDbIndexManager implements IndexManager {
states.put(
toDbIndexState(
config.indexId!,
this.user,
this.uid,
nextSequenceNumber,
offset
)
Expand Down
5 changes: 2 additions & 3 deletions packages/firestore/src/local/local_serializer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -476,13 +475,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),
Expand Down
3 changes: 1 addition & 2 deletions packages/firestore/test/unit/local/local_serializer.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -258,7 +257,7 @@ describe('Local Serializer', () => {

const dbIndexState = toDbIndexState(
/* indexId= */ 1,
User.UNAUTHENTICATED,
/* uid= */ '',
/* sequenceNumber= */ 2,
expected
);
Expand Down
Loading