Skip to content

Commit c5828cc

Browse files
committed
code 30090056
code 30090056
1 parent e95c91b commit c5828cc

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

src/actions/challenge-listing.js

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -191,31 +191,33 @@ function getActiveChallengesDone(
191191
user = decodeToken(tokenV3).handle;
192192
// Handle any errors on this endpoint so that the non-user specific challenges
193193
// 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: [] })));
197198
}
198199
return Promise.all(calls).then(([ch, uch]) => {
200+
let fullCH = ch;
199201
/* uch array contains challenges where the user is participating in
200202
* some role. The same challenge are already listed in res array, but they
201203
* are not attributed to the user there. This block of code marks user
202204
* challenges in an efficient way. */
203205
if (uch) {
204206
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 */
215213
});
216214
}
217215

218-
let { challenges, meta } = ch;
216+
if (uch) {
217+
fullCH = uch;
218+
}
219+
let { challenges } = fullCH;
220+
let { meta } = ch;
219221
// filter by date range and re-compute meta
220222
// we can safely remove the next two lines when backend support date range
221223
challenges = filterUtil.filterByDate(challenges, frontFilter);

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy