Skip to content

Commit 8f1cadc

Browse files
committed
fix for issue #4383
1 parent 63d7e1e commit 8f1cadc

File tree

2 files changed

+16
-22
lines changed

2 files changed

+16
-22
lines changed

src/actions/members.js

+2-1
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,7 @@ async function getActiveChallengesInit(handle, uuid) {
146146
async function getActiveChallengesDone(handle, uuid, tokenV3) {
147147
const filter = { status: 'Active' };
148148
const service = getChallengesService(tokenV3);
149+
const memberInfo = await getService(tokenV3).getMemberInfo(handle);
149150
/* TODO: Reuse `getAll` from `actions/challenge-listing`
150151
/* after it moved from `community-app` to here.
151152
*/
@@ -160,7 +161,7 @@ async function getActiveChallengesDone(handle, uuid, tokenV3) {
160161
});
161162
}
162163
const calls = [
163-
getAll(params => service.getUserChallenges(handle, filter, params)),
164+
getAll(params => service.getUserChallenges(memberInfo.userId, filter, params)),
164165
];
165166

166167
const [challenges] = await Promise.all(calls);

src/services/challenges.js

+14-21
Original file line numberDiff line numberDiff line change
@@ -452,29 +452,22 @@ class ChallengesService {
452452
const userFilters = _.cloneDeep(filters);
453453
ChallengesService.updateFiltersParamsForGettingMemberChallenges(userFilters, params);
454454

455-
const userChallenges = await this.private.apiV5.get(`/resources/${userId}/challenges`)
456-
.then(checkErrorV5).then(res => res);
457-
458-
let chResponse = null;
459-
if (userChallenges.result && userChallenges.result.length > 0) {
460-
const query = {
461-
...params,
462-
...userFilters,
463-
ids: userChallenges.result,
464-
};
465-
const endpoint = '/challenges';
466-
const url = `${endpoint}?${qs.stringify(_.omit(query, ['limit', 'offset', 'technologies']))}`;
467-
chResponse = await this.private.apiV5.get(url)
468-
.then(checkErrorV5).then((res) => {
469-
res.result.forEach(item => normalizeChallenge(item, userId));
470-
return res;
471-
});
472-
}
455+
const query = {
456+
...params,
457+
...userFilters,
458+
memberId: userId,
459+
};
460+
const url = `/challenges?${qs.stringify(_.omit(query, ['limit', 'offset', 'technologies']))}`;
461+
const userChallenges = await this.private.apiV5.get(url)
462+
.then(checkErrorV5)
463+
.then((res) => {
464+
res.result.forEach(item => normalizeChallenge(item, userId));
465+
return res.result;
466+
});
473467

474-
const chResult = (chResponse && chResponse.result) || [];
475468
return {
476-
challenges: chResult,
477-
totalCount: chResult.length,
469+
challenges: userChallenges,
470+
totalCount: userChallenges.length,
478471
};
479472
}
480473

0 commit comments

Comments
 (0)