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

Only set timestampsInSnapshots when explicitly requested via prop #42

Merged

Conversation

tomsun
Copy link
Contributor

@tomsun tomsun commented Mar 4, 2019

As of [email protected] timestampsInSnapshots seems to be true implicitly
(example: #39 ) i.e. the corresponding prop and logic in react-firestore is unneccessary for anyone who is up-to-date. This PR keeps the prop around for backwards compatibility, but only acts on it when set explicitly.

Furthermore: another reason not calling settings() implicitly and unconditionally
within react-firestore: calling settings() multiple times is not supported.

If your app interacts with Firestore prior to using FirestoreProvider,
FirestoreProvider's settings() call will get you into trouble:

Uncaught FirebaseError: Firestore has already been started
and its settings can no longer be changed. You can only call settings()
before calling any other methods on a Firestore object

(This PR is possibly also a more graceful alternative to #37 )

@tomsun
Copy link
Contributor Author

tomsun commented Mar 4, 2019

CI complains:

Warning: Failed prop type: The prop useTimestampsInSnapshots is marked as required in FirestoreProvider, but its value is undefined.

I'm not fully up to speed with how to mark a prop as optional within the conventions in use. Other than that I think this approach should be fine.

@tomsun tomsun force-pushed the timestamps-in-snapshots-conditionally branch from 80b4010 to ec64eb7 Compare March 4, 2019 10:26
@tomsun
Copy link
Contributor Author

tomsun commented Mar 4, 2019

Got the warning locally in the console too, just didn't notice it at first...

Dropping .isRequired from PropTypes.bool.isRequired seems to do it (obviously... :-P )

@tomsun tomsun force-pushed the timestamps-in-snapshots-conditionally branch from ec64eb7 to 5847866 Compare March 4, 2019 10:32
@codecov
Copy link

codecov bot commented Mar 4, 2019

Codecov Report

Merging #42 into master will not change coverage.
The diff coverage is 100%.

Impacted file tree graph

@@          Coverage Diff          @@
##           master    #42   +/-   ##
=====================================
  Coverage     100%   100%           
=====================================
  Files           6      6           
  Lines          86     89    +3     
  Branches       19     19           
=====================================
+ Hits           86     89    +3
Impacted Files Coverage Δ
src/FirestoreProvider.js 100% <100%> (ø) ⬆️
src/Firestore.js 100% <0%> (ø) ⬆️
src/FirestoreDocument.js 100% <0%> (ø) ⬆️
src/FirestoreCollection.js 100% <0%> (ø) ⬆️
src/withFirestore.js 100% <0%> (ø) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ef0cfe5...2a44eea. Read the comment docs.

@tomsun
Copy link
Contributor Author

tomsun commented Mar 4, 2019

Adjusted expectations in tests to meet PR's suggested behavior

@green-arrow
Copy link
Owner

@tomsun - I just merged a PR that upgraded to the new React context. It turns out that the PR also marked this prop as not required. However it is still being set in defaultProps. Would you mind rebasing your PR off of master?

As of [email protected] timestampsInSnapshots is true implicitly
green-arrow#39

Furthermore: calling settings() multiple times is not supported.
If your app interacts with Firestore prior to using <FirestoreProvider>,
FirestoreProvider's settings() call will get you into trouble:

Uncaught FirebaseError: Firestore has already been started
and its settings can no longer be changed. You can only call settings()
before calling any other methods on a Firestore object
@tomsun tomsun force-pushed the timestamps-in-snapshots-conditionally branch from 5847866 to 2a44eea Compare March 11, 2019 08:45
@tomsun
Copy link
Contributor Author

tomsun commented Mar 11, 2019

@green-arrow sure! done

@arnaskro
Copy link

arnaskro commented Apr 6, 2019

Any plans on getting this merged to master any time soon?

@green-arrow green-arrow merged commit e75e03d into green-arrow:master Apr 6, 2019
@green-arrow
Copy link
Owner

@tomsun @arnaskro - sorry, I must’ve missed when this was updated!

@green-arrow
Copy link
Owner

🎉 This PR is included in version 1.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants