Skip to content

Commit c12daea

Browse files
authored
v0.5.5
* fix(orderedReducer): `LISTENER_RESPONSE` and `DOCUMENT_REMOVED` actions correctly updating state for sub-collections * feat(tests): tests added for success callback and error callback arguments of `setListener` method * fix(core): only copy public methods from `firebase.firestore()` instance - #93, #108 * fix(actions): `runTransaction` no longer failing - #108 * fix(orderedReducer): empty listener response correctly updates state when using `storeAs` * fix(orderedReducer): fix merge setting (`merge.collection` to `merge.collections`) - @danleavitt0 * feat(actions): attempting to delete sub collection at any level throw (previously only top level) * feat(tests): Add tests for success and error callbacks of setListener * fix(orderedReducer): return state directly for non-matching action types * fix(deps): lock prettier version to 1.10.0 (prevents build fail on Travis)
2 parents 4b8acba + 87589a1 commit c12daea

21 files changed

+475
-201
lines changed

.travis.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ sudo: false
33
language: node_js
44

55
node_js:
6-
- 6.11.5
7-
- 8
8-
- 9 # LTS
6+
- 6.14.0 # Cloud Functions Runtime
7+
- 9
8+
- 10
99

1010
notifications:
1111
email:

README.md

+12-14
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ npm install --save react-redux-firebase
3838
```javascript
3939
import { createStore, combineReducers, compose } from 'redux'
4040
import { reduxFirestore, firestoreReducer } from 'redux-firestore'
41-
import firebase from 'firebase'
41+
import firebase from 'firebase/app'
42+
import 'firebase/auth'
43+
import 'firebase/database'
4244
import 'firebase/firestore'
4345

4446
const firebaseConfig = {} // from Firebase Console
@@ -268,6 +270,7 @@ store.firestore.setListeners([
268270
// props.store.firestore.get('cities/SF'),
269271
```
270272

273+
**Note:** When nesting sub-collections, [`storeAs`](#storeas) should be used for more optimal state updates.
271274

272275
##### Where
273276

@@ -292,7 +295,7 @@ Multiple `where` queries are as simple as passing multiple argument arrays (each
292295
},
293296
```
294297

295-
*Should only be used with collections*
298+
*Can only be used with collections*
296299

297300
##### orderBy
298301

@@ -318,7 +321,7 @@ Multiple `orderBy`s are as simple as passing multiple argument arrays (each one
318321
},
319322
```
320323

321-
*Should only be used with collections*
324+
*Can only be used with collections*
322325

323326
##### limit
324327

@@ -331,7 +334,7 @@ Limit the query to a certain number of results
331334
},
332335
```
333336

334-
*Should only be used with collections*
337+
*Can only be used with collections*
335338

336339
##### startAt
337340

@@ -347,7 +350,7 @@ Limit the query to a certain number of results
347350
},
348351
```
349352

350-
*Should only be used with collections*
353+
*Can only be used with collections*
351354

352355
##### startAfter
353356

@@ -363,7 +366,7 @@ Limit the query to a certain number of results
363366
},
364367
```
365368

366-
*Should only be used with collections*
369+
*Can only be used with collections*
367370

368371
##### endAt
369372

@@ -380,7 +383,7 @@ Limit the query to a certain number of results
380383
},
381384
```
382385

383-
*Should only be used with collections*
386+
*Can only be used with collections*
384387

385388
##### endBefore
386389

@@ -397,7 +400,7 @@ Limit the query to a certain number of results
397400
},
398401
```
399402

400-
*Should only be used with collections*
403+
*Can only be used with collections*
401404

402405
##### storeAs
403406

@@ -451,11 +454,6 @@ export default enhance(SomeComponent)
451454

452455
## Config Options
453456

454-
#### enableLogging
455-
Default: `false`
456-
457-
Whether or not to enable Firebase client logging.
458-
459457
#### logListenerError
460458
Default: `true`
461459

@@ -471,7 +469,7 @@ Default: `false`
471469

472470
Whether or not to allow multiple listeners to be attached for the same query. If a function is passed the arguments it receives are `listenerToAttach`, `currentListeners`, and the function should return a boolean.
473471

474-
### oneListenerPerPath
472+
#### oneListenerPerPath
475473
Default: `false`
476474

477475
If set to true redux-firestore will attach a listener on the same path just once & will count how many the listener was set. When you try to unset the lisnter, it won't unset until you have less than 1 listeners on this path

examples/basic/package-lock.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/basic/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"react-scripts": "1.1.4",
1212
"recompose": "^0.27.0",
1313
"redux": "^4.0.0",
14-
"redux-firestore": "^0.5.2"
14+
"redux-firestore": "latest"
1515
},
1616
"scripts": {
1717
"start": "react-scripts start",

examples/basic/src/Todos.js

+8-10
Original file line numberDiff line numberDiff line change
@@ -34,17 +34,19 @@ Todos.propTypes = {
3434
})
3535
}
3636

37+
const listenerSettings = {
38+
collection: 'todos',
39+
orderBy: ['createdAt', 'desc'],
40+
limit: 10
41+
}
42+
3743
// Create HOC that loads data and adds it as todos prop
3844
const enhance = compose(
3945
// add redux store (from react context) as a prop
4046
withFirestore,
4147
// Handler functions as props
4248
withHandlers({
43-
loadData: props => err => props.firestore.setListener({
44-
collection: 'todos',
45-
orderBy: ['createdAt', 'desc'],
46-
limit: 10
47-
}),
49+
loadData: props => err => props.firestore.setListener(listenerSettings),
4850
onNewSubmit: props => newTodo =>
4951
props.firestore.add('todos', {
5052
...newTodo,
@@ -59,11 +61,7 @@ const enhance = compose(
5961
this.props.loadData()
6062
},
6163
componentWillUnmount() {
62-
this.props.firestore.unsetListener({
63-
collection: 'todos',
64-
orderBy: ['createdAt', 'desc'],
65-
limit: 10
66-
})
64+
this.props.firestore.unsetListener(listenerSettings)
6765
}
6866
}),
6967
// Connect todos from redux state to props.todos

examples/basic/src/createStore.js

+7-7
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
import { createStore, compose } from 'redux'
22
import { reduxFirestore } from 'redux-firestore'
33
import firebase from 'firebase/app'
4+
import 'firebase/database'
5+
import 'firebase/auth'
46
import 'firebase/firestore'
57
import { fbConfig } from './config'
68
import rootReducer from './reducer'
79

8-
// import 'firebase/storage'
9-
10-
firebase.initializeApp(fbConfig)
11-
12-
// Provide timestamp settings to silence warning about deprecation
13-
firebase.firestore().settings({ timestampsInSnapshots: true })
14-
1510
export default function configureStore(initialState, history) {
1611
const enhancers = []
1712

13+
firebase.initializeApp(fbConfig)
14+
15+
// Provide timestamp settings to silence warning about deprecation
16+
firebase.firestore().settings({ timestampsInSnapshots: true })
17+
1818
// Dev tools store enhancer
1919
const devToolsExtension = window.devToolsExtension;
2020
if (typeof devToolsExtension === 'function') {

examples/complete/package-lock.json

+33-8
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

examples/complete/package.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@
3232
"react-dom": "^15.5.4",
3333
"react-google-button": "^0.3.0",
3434
"react-redux": "^5.0.4",
35-
"react-redux-firebase": "^2.1.1",
35+
"react-redux-firebase": "latest",
3636
"react-router": "^3.0.0",
3737
"react-tap-event-plugin": "^2.0.1",
3838
"redbox-react": "^1.3.6",
3939
"redux": "^3.6.0",
4040
"redux-auth-wrapper": "^1.0.0",
41-
"redux-firestore": "*",
41+
"redux-firestore": "latest",
4242
"redux-form": "^6.6.1",
4343
"redux-form-material-ui": "^4.2.0",
4444
"redux-thunk": "^2.2.0",
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,51 @@
11
import React from 'react'
2+
import PropTypes from 'prop-types'
23
import Theme from 'theme'
34
import { connect } from 'react-redux'
45
import { compose, lifecycle, withHandlers } from 'recompose'
6+
import { withFirestore } from 'react-redux-firebase'
57
import { withStore } from 'utils/components'
68
import classes from './Home.scss'
7-
const authWrapperUrl = 'https://github.com/mjrussell/redux-auth-wrapper'
8-
const reactRouterUrl = 'https://github.com/ReactTraining/react-router'
99

10-
export const Home = ({ todos }) => (
10+
const Home = ({ todos }) => (
1111
<div
1212
className={classes.container}
1313
style={{ color: Theme.palette.primary2Color }}>
1414
<div className="flex-row-center">
1515
<h2>Home Route</h2>
1616
</div>
1717
<div>
18-
{
19-
todos.map((todo, i) => (
20-
<div key={`${todo.id}-${i}`}>
21-
{JSON.stringify(todo)}
22-
</div>
23-
))
24-
}
18+
{todos.map((todo, i) => (
19+
<div key={`${todo.id}-${i}`}>{JSON.stringify(todo)}</div>
20+
))}
2521
</div>
2622
</div>
2723
)
2824

29-
export default compose(
25+
Home.propTypes = {
26+
todos: PropTypes.array
27+
}
28+
29+
const enhance = compose(
3030
withStore,
31+
withFirestore,
3132
withHandlers({
3233
loadCollection: props => props.store.firestore.get,
33-
onDoneClick: props => (key, done = false) =>
34-
props.store.firestore.update('todos', key, { done }),
3534
onNewSubmit: props => newTodo =>
36-
props.store.firestore.add('todos', { ...newTodo, owner: 'Anonymous' })
35+
props.store.firestore.add('todos', {
36+
...newTodo,
37+
owner: props.uid || 'Anonymous'
38+
})
3739
}),
3840
lifecycle({
3941
componentWillMount() {
4042
this.props.loadCollection('todos')
4143
}
4244
}),
43-
connect(({ firestore }) => ({
45+
connect(({ firestore, firebase }) => ({
4446
todos: firestore.ordered.todos || [],
45-
uid: firestore.profile.uid
47+
uid: firebase.auth.uid
4648
}))
47-
)(Home)
49+
)
50+
51+
export default enhance(Home)

examples/complete/src/store/createStore.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import { applyMiddleware, compose, createStore } from 'redux'
22
import { browserHistory } from 'react-router'
3-
import firebase from 'firebase'
3+
import firebase from 'firebase/app'
44
import 'firebase/firestore'
5+
import 'firebase/database'
6+
import 'firebase/auth'
57
import { reduxFirestore } from 'redux-firestore'
68
import { reactReduxFirebase } from 'react-redux-firebase'
79
import makeRootReducer from './reducers'
@@ -34,7 +36,7 @@ export default (initialState = {}) => {
3436
}
3537

3638
firebase.initializeApp(fbConfig)
37-
firebase.firestore()
39+
firebase.firestore().settings({ timestampsInSnapshots: true })
3840

3941
// ======================================================
4042
// Store Instantiation and HMR Setup

package-lock.json

+5-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)