@@ -197,26 +197,27 @@ function getActiveChallengesDone(
197
197
} ) . catch ( ( ) => ( { challenges : [ ] } ) ) ) ;
198
198
}
199
199
return Promise . all ( calls ) . then ( ( [ ch , uch ] ) => {
200
+ let fullCH = ch ;
200
201
/* uch array contains challenges where the user is participating in
201
202
* some role. The same challenge are already listed in res array, but they
202
203
* are not attributed to the user there. This block of code marks user
203
204
* challenges in an efficient way. */
204
205
if ( uch ) {
205
206
const map = { } ;
206
- uch . challenges . forEach ( ( item ) => { map [ item . id ] = item ; } ) ;
207
- ch . challenges . forEach ( ( item ) => {
208
- if ( map [ item . id ] ) {
209
- /* It is fine to reassing, as the array we modifying is created just
210
- * above within the same function. */
211
- /* eslint-disable no-param-reassign */
212
- item . users [ user ] = true ;
213
- item . userDetails = map [ item . id ] . userDetails ;
214
- /* eslint-enable no-param-reassign */
215
- }
207
+ uch . challenges . forEach ( ( item ) => {
208
+ map [ item . id ] = item ;
209
+ /* eslint-disable no-param-reassign */
210
+ item . users [ user ] = true ;
211
+ item . userDetails = map [ item . id ] . userDetails ;
212
+ /* eslint-enable no-param-reassign */
216
213
} ) ;
217
214
}
218
215
219
- let { challenges, meta } = ch ;
216
+ if ( uch ) {
217
+ fullCH = uch ;
218
+ }
219
+ let { challenges } = fullCH ;
220
+ let { meta } = ch ;
220
221
// filter by date range and re-compute meta
221
222
// we can safely remove the next two lines when backend support date range
222
223
challenges = filterUtil . filterByDate ( challenges , frontFilter ) ;
0 commit comments