Skip to content

feat(ui_firestore): add includeMetadataChanges parameter to FirestoreQueryBuilder #349

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

cpunion
Copy link

@cpunion cpunion commented May 22, 2024

Description

Currently FirestoreListView can't get metadata changes, the FirestoreQueryBuilder component calls Query<Document>.snapshots() without includeMetadataChanges parameter.

Related Issues

Checklist

Before you create this PR confirm that it meets all requirements listed below by checking the relevant checkboxes ([x]).
This will ensure a smooth and quick review process. Updating the pubspec.yaml and changelogs is not required.

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • My PR includes unit or integration tests for all changed/updated/fixed behaviors (See Contributor Guide).
  • All existing and new tests are passing.
  • I updated/added relevant documentation (doc comments with ///).
  • The analyzer (melos run analyze) does not report any problems on my PR.
  • All unit tests pass (melos run test:unit:all doesn't fail).
  • I read and followed the Flutter Style Guide.
  • I signed the CLA.
  • I am willing to follow-up on review comments in a timely manner.

Breaking Change

Does your PR require plugin users to manually update their apps to accommodate your change?

  • Yes, this is a breaking change.
  • No, this is not a breaking change.

@cpunion cpunion force-pushed the includeMetadataChanges branch from 70d3f0b to 0675408 Compare May 22, 2024 05:32
@cpunion cpunion changed the title add includeMetadataChanges parameter to FirestoreQueryBuilder feat(ui_firestore): add includeMetadataChanges parameter to FirestoreQueryBuilder May 22, 2024
@cpunion
Copy link
Author

cpunion commented May 22, 2024

I am not sure if there is a way to directly specify includeMetadataChanges when constructing the query. If there is such a method, then this PR is unnecessary.

@russellwheatley russellwheatley changed the title feat(ui_firestore): add includeMetadataChanges parameter to FirestoreQueryBuilder feat(ui_firestore): add includeMetadataChanges parameter to FirestoreQueryBuilder Jun 6, 2024
@russellwheatley
Copy link
Member

@cpunion - This seems good to me. I think we should also update here: https://github.com/firebase/FirebaseUI-Flutter/blob/main/packages/firebase_ui_firestore/lib/src/table_builder.dart#L267

Probably should be able to pass it into FirestoreDataTable if you could update, please?

@russellwheatley russellwheatley added the blocked: customer response Waiting for customer response, e.g. more information was requested. label Jun 6, 2024
@cpunion
Copy link
Author

cpunion commented Jun 6, 2024

@cpunion - This seems good to me. I think we should also update here: https://github.com/firebase/FirebaseUI-Flutter/blob/main/packages/firebase_ui_firestore/lib/src/table_builder.dart#L267

Probably should be able to pass it into FirestoreDataTable if you could update, please?

There isn't any listen call, so I think it need a big change if add includeMetadataChanges?

@russellwheatley
Copy link
Member

@cpunion - We can leave that for another time. Do you mind adding a simple test that passes in includeMetadataChanges and checks that metadata is passed in with snapshot here: https://github.com/firebase/FirebaseUI-Flutter/blob/main/tests/integration_test/firebase_ui_firestore/firestore_list_view_test.dart

Thanks 😄

@cpunion cpunion force-pushed the includeMetadataChanges branch from 0675408 to f6810c7 Compare June 11, 2024 05:55
@cpunion
Copy link
Author

cpunion commented Jun 12, 2024

@cpunion - We can leave that for another time. Do you mind adding a simple test that passes in includeMetadataChanges and checks that metadata is passed in with snapshot here: https://github.com/firebase/FirebaseUI-Flutter/blob/main/tests/integration_test/firebase_ui_firestore/firestore_list_view_test.dart

I will try to add a test.

@cpunion
Copy link
Author

cpunion commented Jun 17, 2024

@russellwheatley It seems that metadata changes too quickly to be captured by tester.pump*. For example, when creating and updating a document, collection.snapshots().listen(includeMetadataChanges: true) will receive a series of events in a short period of time, like this:

// These are the events from collection.add({value: 1})
received event, hasPendingWrites: true, isFromCache: true, data: ({value: 1})
received event, hasPendingWrites: true, isFromCache: false, data: ()
received event, hasPendingWrites: false, isFromCache: false, data: ()

// These are the events from collection.doc('docId').update({value: 2})
received event, hasPendingWrites: true, isFromCache: false, data: ({value: 2})
received event, hasPendingWrites: false, isFromCache: false, data: ()

When the FirestoreQueryBuilder listens to the collection, multiple setState calls occur in a very short time. tester.pump* only catches the last one, and can't catches changes of hasPendingWrites and isFromCache. I'm not sure how to properly test this case. Could you please help me? Thanks.

@russellwheatley
Copy link
Member

@cpunion - could you show me what test you wrote? You can use a Completer to wait for something to return. E.g: https://github.com/firebase/flutterfire/blob/main/packages/cloud_firestore/cloud_firestore/example/integration_test/web_snapshot_listeners.dart#L36

@github-actions github-actions bot added the Needs Attention OP created or responded to issue and it needs attention. label Oct 29, 2024
@cpunion
Copy link
Author

cpunion commented Oct 30, 2024

Copy link

Hello 👋, this PR has been opened for more than 2 months with no activity on it.

If you think this is a mistake please comment and ping a maintainer to get this merged ASAP! Thanks for contributing!

You have 15 days until this gets closed automatically

@github-actions github-actions bot added the Stale Issue with no recent activity label Nov 27, 2024
@russellwheatley russellwheatley added Keep Open Keep PR or issue open and removed Stale Issue with no recent activity labels Nov 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked: customer response Waiting for customer response, e.g. more information was requested. Keep Open Keep PR or issue open Needs Attention OP created or responded to issue and it needs attention.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants