@@ -191,31 +191,33 @@ function getActiveChallengesDone(
191
191
user = decodeToken ( tokenV3 ) . handle ;
192
192
// Handle any errors on this endpoint so that the non-user specific challenges
193
193
// will still be loaded.
194
- calls . push ( getAll (
195
- params => service . getUserChallenges ( user , filter , params ) . catch ( ( ) => ( { challenges : [ ] } ) ) ,
196
- ) ) ;
194
+ calls . push ( service . getUserChallenges ( user , filter , {
195
+ limit : PAGE_SIZE ,
196
+ offset : page * PAGE_SIZE ,
197
+ } ) . catch ( ( ) => ( { challenges : [ ] } ) ) ) ;
197
198
}
198
199
return Promise . all ( calls ) . then ( ( [ ch , uch ] ) => {
200
+ let fullCH = ch ;
199
201
/* uch array contains challenges where the user is participating in
200
202
* some role. The same challenge are already listed in res array, but they
201
203
* are not attributed to the user there. This block of code marks user
202
204
* challenges in an efficient way. */
203
205
if ( uch ) {
204
206
const map = { } ;
205
- uch . challenges . forEach ( ( item ) => { map [ item . id ] = item ; } ) ;
206
- ch . challenges . forEach ( ( item ) => {
207
- if ( map [ item . id ] ) {
208
- /* It is fine to reassing, as the array we modifying is created just
209
- * above within the same function. */
210
- /* eslint-disable no-param-reassign */
211
- item . users [ user ] = true ;
212
- item . userDetails = map [ item . id ] . userDetails ;
213
- /* eslint-enable no-param-reassign */
214
- }
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 */
215
213
} ) ;
216
214
}
217
215
218
- let { challenges, meta } = ch ;
216
+ if ( uch ) {
217
+ fullCH = uch ;
218
+ }
219
+ let { challenges } = fullCH ;
220
+ let { meta } = ch ;
219
221
// filter by date range and re-compute meta
220
222
// we can safely remove the next two lines when backend support date range
221
223
challenges = filterUtil . filterByDate ( challenges , frontFilter ) ;
0 commit comments