Skip to content

Commit ee1759f

Browse files
issue-4380 - Hotfix
1 parent ce75876 commit ee1759f

File tree

1 file changed

+5
-16
lines changed

1 file changed

+5
-16
lines changed

src/services/challenges.js

+5-16
Original file line numberDiff line numberDiff line change
@@ -339,18 +339,11 @@ class ChallengesService {
339339
.then(res => res.challenges);
340340
}
341341

342-
// TEMP FIX until API was fixed
343-
try {
344-
const registrants = await this.getChallengeRegistrants(challenge.id);
345-
challenge.registrants = registrants;
346-
} catch (err) {
347-
challenge.registrants = [];
348-
}
342+
const registrants = await this.getChallengeRegistrants(challenge.id);
343+
challenge.registrants = registrants;
349344

350345
if (memberId) {
351-
const userChallenges = await this.private.apiV5.get(`/resources/${memberId}/challenges`)
352-
.then(checkErrorV5).then(res => res.result);
353-
isRegistered = _.includes(userChallenges, challengeId);
346+
isRegistered = _.some(registrants, r => r.memberId === memberId);
354347
}
355348

356349
challenge.isLegacyChallenge = isLegacyChallenge;
@@ -373,19 +366,15 @@ class ChallengesService {
373366
* @return {Promise} Resolves to the challenge registrants array.
374367
*/
375368
async getChallengeRegistrants(challengeId) {
376-
const roleId = await this.getRoleId('Submitter');
369+
/* If no token provided, resource will return Submitter role only */
377370
const params = {
378371
challengeId,
379-
roleId,
372+
roleId: this.private.tokenV3 ? await this.getRoleId('Submitter') : '',
380373
};
381374

382375
const registrants = await this.private.apiV5.get(`/resources?${qs.stringify(params)}`)
383376
.then(checkErrorV5).then(res => res.result);
384377

385-
if (_.isEmpty(registrants)) {
386-
throw new Error('Resource Role not found!');
387-
}
388-
389378
return registrants || [];
390379
}
391380

0 commit comments

Comments
 (0)