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

Conversation

dconeybe
Copy link
Contributor

This PR makes a tiny change to an internal function named toDbIndexState(). Formerly, this function had a User argument, of which only the uid property was used. If the given user was unauthenticated, then the empty string was used instead. This, however, is an implementation detail of the single call site which uses an empty string as the "uid" of an unauthenticated user.

To avoid this implementation detail bleeding into the toDbIndexState() function, this PR changes the argument from a User to simply a string, whose value is the "uid" to use. The caller, then is responsible for mapping the unauthenticated user to the correct string, keeping that implementation detail in one place.

This PR does not actually change any functionality, but merely cleans up the code a bit.

@dconeybe dconeybe self-assigned this Dec 24, 2023
Copy link

changeset-bot bot commented Dec 24, 2023

⚠️ No Changeset found

Latest commit: 1f9fddd

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@dconeybe dconeybe changed the title Firestore: local_serializer.ts: change toDbIndexState() arguments from user:User to uid:string Firestore: local_serializer.ts: change toDbIndexState() argument from user:User to uid:string Dec 24, 2023
@google-oss-bot
Copy link
Contributor

google-oss-bot commented Dec 24, 2023

Size Report 1

Affected Products

  • @firebase/firestore

    TypeBase (537d399)Merge (5235f8f)Diff
    browser375 kB375 kB-22 B (-0.0%)
    esm5360 kB360 kB-22 B (-0.0%)
    main577 kB577 kB-27 B (-0.0%)
    module375 kB375 kB-22 B (-0.0%)
    react-native375 kB375 kB-22 B (-0.0%)
  • bundle

    TypeBase (537d399)Merge (5235f8f)Diff
    firestore (Persistence)302 kB302 kB-22 B (-0.0%)
    firestore (Read Write w Persistence)321 kB321 kB-22 B (-0.0%)
  • firebase

    TypeBase (537d399)Merge (5235f8f)Diff
    firebase-compat.js779 kB779 kB-22 B (-0.0%)
    firebase-firestore-compat.js341 kB341 kB-22 B (-0.0%)
    firebase-firestore.js434 kB434 kB-22 B (-0.0%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/2kgygsnnyy.html

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Dec 24, 2023

Size Analysis Report 1

Affected Products

  • @firebase/firestore

    • enableIndexedDbPersistence

      Size

      TypeBase (537d399)Merge (5235f8f)Diff
      size186 kB186 kB-22 B (-0.0%)
      size-with-ext-deps258 kB258 kB-22 B (-0.0%)
    • enableMultiTabIndexedDbPersistence

      Size

      TypeBase (537d399)Merge (5235f8f)Diff
      size222 kB222 kB-22 B (-0.0%)
      size-with-ext-deps294 kB294 kB-22 B (-0.0%)
    • persistentLocalCache

      Size

      TypeBase (537d399)Merge (5235f8f)Diff
      size183 kB183 kB-22 B (-0.0%)
      size-with-ext-deps255 kB255 kB-22 B (-0.0%)
    • persistentMultipleTabManager

      Size

      TypeBase (537d399)Merge (5235f8f)Diff
      size219 kB218 kB-22 B (-0.0%)
      size-with-ext-deps291 kB291 kB-22 B (-0.0%)
    • persistentSingleTabManager

      Size

      TypeBase (537d399)Merge (5235f8f)Diff
      size183 kB183 kB-22 B (-0.0%)
      size-with-ext-deps255 kB255 kB-22 B (-0.0%)

Test Logs

  1. https://storage.googleapis.com/firebase-sdk-metric-reports/Tneg2vrWGE.html

@dconeybe dconeybe marked this pull request as ready for review January 2, 2024 16:36
@dconeybe dconeybe requested review from a team as code owners January 2, 2024 16:36
@dconeybe dconeybe requested a review from cherylEnkidu January 2, 2024 16:36
@@ -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!

@dconeybe dconeybe merged commit 096542a into master Jan 2, 2024
43 of 44 checks passed
@dconeybe dconeybe deleted the dconeybe/ToDbIndexStateUserArgToUid branch January 2, 2024 21:10
@firebase firebase locked and limited conversation to collaborators Feb 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants