@@ -339,18 +339,11 @@ class ChallengesService {
339
339
. then ( res => res . challenges ) ;
340
340
}
341
341
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 ;
349
344
350
345
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 ) ;
354
347
}
355
348
356
349
challenge . isLegacyChallenge = isLegacyChallenge ;
@@ -373,19 +366,15 @@ class ChallengesService {
373
366
* @return {Promise } Resolves to the challenge registrants array.
374
367
*/
375
368
async getChallengeRegistrants ( challengeId ) {
376
- const roleId = await this . getRoleId ( ' Submitter' ) ;
369
+ /* If no token provided, resource will return Submitter role only */
377
370
const params = {
378
371
challengeId,
379
- roleId,
372
+ roleId : this . private . tokenV3 ? await this . getRoleId ( 'Submitter' ) : '' ,
380
373
} ;
381
374
382
375
const registrants = await this . private . apiV5 . get ( `/resources?${ qs . stringify ( params ) } ` )
383
376
. then ( checkErrorV5 ) . then ( res => res . result ) ;
384
377
385
- if ( _ . isEmpty ( registrants ) ) {
386
- throw new Error ( 'Resource Role not found!' ) ;
387
- }
388
-
389
378
return registrants || [ ] ;
390
379
}
391
380
0 commit comments