Skip to content

Commit 6f4bba5

Browse files
Fix issue with my challenges bucket
1 parent de43180 commit 6f4bba5

File tree

5 files changed

+76
-83
lines changed

5 files changed

+76
-83
lines changed

__tests__/__snapshots__/index.js.snap

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -428,14 +428,17 @@ Object {
428428
"countReset": [Function],
429429
"debug": [Function],
430430
"dir": [Function],
431+
"dirxml": [Function],
431432
"error": [Function],
432433
"group": [Function],
433434
"groupCollapsed": [Function],
434435
"groupEnd": [Function],
435436
"info": [Function],
436437
"log": [Function],
438+
"table": [Function],
437439
"time": [Function],
438440
"timeEnd": [Function],
441+
"timeLog": [Function],
439442
"trace": [Function],
440443
"warn": [Function],
441444
},

dist/dev/index.js

Lines changed: 62 additions & 62 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/prod/index.js

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/actions/challenge-listing.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ const { fireErrorMessage } = errors;
1616
const { getService } = services.challenge;
1717
const { getReviewOpportunitiesService } = services.reviewOpportunities;
1818
const { PAGE_SIZE, REVIEW_OPPORTUNITY_PAGE_SIZE } = config;
19-
2019
/**
2120
* Process filter
2221
* When filter includes Data Science track, still should be
@@ -205,7 +204,7 @@ function getActiveChallengesDone(
205204
/* uch array contains challenges where the user is participating in
206205
* some role. The same challenge are already listed in res array, but they
207206
* are not attributed to the user there. This block of code marks user
208-
* challenges in an efficient way. */
207+
// * challenges in an efficient way. */
209208
if (uch) {
210209
const map = {};
211210
uch.challenges.forEach((item) => { map[item.id] = item; });
@@ -226,6 +225,10 @@ function getActiveChallengesDone(
226225
// we can safely remove the next two lines when backend support date range
227226
challenges = filterUtil.filterByDate(challenges, frontFilter);
228227
meta = filterUtil.newMeta(meta, challenges, frontFilter);
228+
if (bucket === 'my') {
229+
const { challenges: u } = uch;
230+
challenges = u;
231+
}
229232
return {
230233
uuid,
231234
handle: tokenV3 ? user : null,

src/reducers/challenge-listing.js

Lines changed: 6 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ import { logger, errors, challenge as challengeUtils } from '../utils';
1313
const { fireErrorMessage } = errors;
1414
const { filter: Filter } = challengeUtils;
1515
const { BUCKETS, BUCKET_DATA, getBuckets } = challengeUtils.buckets;
16-
1716
/**
1817
* Process challenge data for bucket
1918
* @param handle user handle
@@ -187,22 +186,16 @@ function onGetActiveChallengesDone(state, { error, payload }) {
187186
? item => !ids.has(item.id)
188187
: item => !ids.has(item.id) && item.status !== 'ACTIVE';
189188

190-
const data = processBucketData(
191-
handle, state.challenges, loaded, bucket, state.sorts, sort, filter,
192-
);
193189
newChallenges = _.cloneDeep(state.challenges);
194-
newChallenges[bucket] = data;
190+
let oldData = newChallenges[bucket];
191+
if (!oldData) {
192+
oldData = [];
193+
}
194+
newChallenges[bucket] = [...oldData, ...payload.challenges];
195195
otherState.loadingMyChallengesUUID = '';
196-
otherState.allMyChallengesLoaded = checkAllLoaded(state.challenges, bucket, loaded, data);
196+
otherState.allMyChallengesLoaded = newChallenges[bucket].length === meta.myChallengesCount;
197197
otherState.gettingMoreMyChallenges = !otherState.allMyChallengesLoaded;
198198
otherState.meta = _.clone(meta);
199-
/* TODO Due to the meta of backend response is currently not correct,
200-
/* so should update counts after fetch all challenges of bucket */
201-
if (_.get(meta, 'myChallengesCount') !== data.length && otherState.allMyChallengesLoaded) {
202-
otherState.meta.myChallengesCount = data.length;
203-
otherState.meta.allChallengesCount = meta.allChallengesCount
204-
+ data.length - meta.myChallengesCount;
205-
}
206199
}
207200
break;
208201
case BUCKETS.OPEN_FOR_REGISTRATION: {

0 commit comments

Comments
 (0)