Skip to content

Commit 2b1193e

Browse files
committed
fix once and queries
1 parent b0e9d03 commit 2b1193e

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/actions/query.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,11 @@ export const watchEvent = (firebase, dispatch, event, path, dest, onlyLastEvent
197197
}
198198

199199
const runQuery = (q, e, p, params) => {
200+
if (e === 'once') {
201+
q.once('value').then(snapshot => dispatch({ type: SET, path, data: snapshot.val()}))
202+
return;
203+
}
204+
200205
q.on(e, snapshot => {
201206
let data = (e === 'child_removed') ? undefined : snapshot.val()
202207
const resultPath = dest || (e === 'value') ? p : p + '/' + snapshot.key
@@ -208,7 +213,7 @@ export const watchEvent = (firebase, dispatch, event, path, dest, onlyLastEvent
208213
}
209214
}
210215

211-
const populates = filter(params, (param) => params.indexOf('populate'))
216+
const populates = filter(params, (param) => params.indexOf('populate') > -1)
212217
.map(p => p.split('=')[1])
213218

214219
// Dispatch standard if no populates

0 commit comments

Comments
 (0)