Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Fixed query bugs #2 and #3
* Fixes #3 (once query not working)
* Fixes #2 (populate breaks if there is >0 queries)
* Firebase version upped to v3.5.0
  • Loading branch information
Scott Prue committed Oct 17, 2016
commit 3d3070aa242aaf9b845acc8419d027994e46ce62
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"react-redux-firebase"
],
"dependencies": {
"firebase": "^3.4.1",
"firebase": "^3.5.0",
"immutable": "^3.8.1",
"jwt-decode": "^2.1.0",
"lodash": "^4.16.4"
Expand Down
15 changes: 13 additions & 2 deletions src/actions/query.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,15 @@ export const watchEvent = (firebase, dispatch, event, path, dest, onlyLastEvent
}

const runQuery = (q, e, p, params) => {
// Handle once queries
if (e === 'once') {
return q.once('value')
.then(snapshot =>
dispatch({ type: SET, path, data: snapshot.val() })
)
}

// Handle all other queries
q.on(e, snapshot => {
let data = (e === 'child_removed') ? undefined : snapshot.val()
const resultPath = dest || (e === 'value') ? p : p + '/' + snapshot.key
Expand All @@ -208,8 +217,10 @@ export const watchEvent = (firebase, dispatch, event, path, dest, onlyLastEvent
}
}

const populates = filter(params, (param) => params.indexOf('populate'))
.map(p => p.split('=')[1])
// Get list of populates
const populates = filter(params, param =>
params.indexOf('populate') !== -1
).map(p => p.split('=')[1])

// Dispatch standard if no populates
if (!populates || !populates.length) {
Expand Down