Skip to content

Commit db2f1ff

Browse files
authored
v2.0.0-beta.16
* Fix promisesForPopulate to fetch data in all cases * Bump version
1 parent 54ea464 commit db2f1ff

File tree

6 files changed

+8267
-6
lines changed

6 files changed

+8267
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "react-redux-firebase",
3-
"version": "2.0.0-beta.15",
3+
"version": "2.0.0-beta.16",
44
"description": "Redux integration for Firebase. Comes with a Higher Order Components for use with React.",
55
"main": "lib/index.js",
66
"module": "es/index.js",

src/enhancer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ let firebaseInstance
5050
* @param {Array|String} config.profileParamsToPopulate - Parameters within
5151
* profile object to populate. As of `v2.0.0` data is only loaded for population, not actually automatically populated
5252
* (allows access to both unpopulated and populated profile data).
53-
* @param {Boolean} config.autoPopulateProfile - **NOTE**: Not yet enabled for v2.0.0. Whether or not to
53+
* @param {Boolean} config.autoPopulateProfile - **NOTE**: Now enabled for v2.0.0. Whether or not to
5454
* automatically populate profile with data loaded through profileParamsToPopulate config. (default: `true`)
5555
* @param {Boolean} config.setProfilePopulateResults - Whether or not to
5656
* call SET actions for data that results from populating profile to redux under

src/helpers.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ export const populate = (state, path, populates, notSetValue) => {
280280

281281
if (!isArray(data)) {
282282
// check each populate child parameter for existence
283-
const dataHasPopulateChilds = every(populatesForData, p =>
283+
const dataHasPopulateChilds = some(populatesForData, p =>
284284
has(data, p.child)
285285
)
286286

src/utils/populate.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
forEach,
1010
set,
1111
has,
12-
every
12+
some
1313
} from 'lodash'
1414

1515
/**
@@ -137,7 +137,7 @@ export const promisesForPopulate = (firebase, dataKey, originalData, populatesIn
137137
: populatesIn
138138
)
139139

140-
const dataHasPopulateChilds = every(populatesForData, (populate) => (
140+
const dataHasPopulateChilds = some(populatesForData, (populate) => (
141141
has(originalData, populate.child)
142142
))
143143

@@ -162,7 +162,8 @@ export const promisesForPopulate = (firebase, dataKey, originalData, populatesIn
162162
)
163163
})
164164
} else {
165-
// Data is a map of objects, each value has parameters to be populated
165+
// Data is a list of objects, each value has parameters to be populated
166+
// { '1': {someobject}, '2': {someobject} }
166167
forEach(originalData, (d, key) => {
167168
// generate populates for this data item if a fn was passed
168169
const populatesForDataItem = getPopulateObj(isFunction(populatesIn)

tests/unit/utils/populate.spec.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,12 @@ describe('Utils: Populate', () => {
8080
expect(res).to.have.deep.property(`users.${uid}`)
8181
})
8282

83+
it('populates all existing children even if one populates child does not exist', async () => {
84+
populates = [{child: 'collaborators', root: 'users'}, {child: 'nonExistantKey', root: 'users'}]
85+
res = await promisesForPopulate(Firebase, '', { collaborators: { [uid]: true, 'ABC123': true } }, populates)
86+
expect(res).to.have.deep.property(`users.${uid}`)
87+
})
88+
8389
describe('populates list', () => {
8490
it('with single property populate', async () => {
8591
populates = [{child: 'owner', root: 'users'}]

0 commit comments

Comments
 (0)