Skip to content

Commit b91180e

Browse files
hongyu zhouhongyu zhou
hongyu zhou
authored and
hongyu zhou
committed
fix loading performance
1 parent 7ff27b7 commit b91180e

File tree

4 files changed

+72
-82
lines changed

4 files changed

+72
-82
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.

src/actions/challenge-listing.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ function getActiveChallengesDone(
197197
const { userId } = decodeToken(tokenV3);
198198
// Handle any errors on this endpoint so that the non-user specific challenges
199199
// will still be loaded.
200-
calls.push(service.getUserChallenges(userId, user, filter, paginationParams));
200+
calls.push(service.getUserChallenges(userId, user, { status: 'ACTIVE' }, paginationParams));
201201
}
202202
return Promise.all(calls).then(([ch, uch]) => {
203203
// let fullCH = ch;

src/reducers/challenge-listing.js

Lines changed: 6 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -186,12 +186,13 @@ function onGetActiveChallengesDone(state, { error, payload }) {
186186
? item => !ids.has(item.id)
187187
: item => !ids.has(item.id) && item.status !== 'ACTIVE';
188188

189+
const data = processBucketData(
190+
handle, state.challenges, loaded,
191+
bucket, state.sorts, sort, filter, frontFilter,
192+
);
193+
189194
newChallenges = _.cloneDeep(state.challenges);
190-
let oldData = newChallenges[bucket];
191-
if (!oldData) {
192-
oldData = [];
193-
}
194-
newChallenges[bucket] = [...oldData, ...payload.challenges];
195+
newChallenges[bucket] = data;
195196
otherState.loadingMyChallengesUUID = '';
196197
otherState.allMyChallengesLoaded = newChallenges[bucket].length === meta.myChallengesCount;
197198
otherState.gettingMoreMyChallenges = !otherState.allMyChallengesLoaded;
@@ -216,13 +217,6 @@ function onGetActiveChallengesDone(state, { error, payload }) {
216217
otherState.allOpenChallengesLoaded = checkAllLoaded(state.challenges, bucket, loaded, data);
217218
otherState.gettingMoreOpenChallenges = !otherState.allOpenChallengesLoaded;
218219
otherState.meta = _.clone(meta);
219-
/* TODO Due to the meta of backend response is currently not correct,
220-
/* so should update counts after fetch all challenges of bucket */
221-
if (_.get(meta, 'openChallengesCount') !== data.length && otherState.allOpenChallengesLoaded) {
222-
otherState.meta.openChallengesCount = data.length;
223-
otherState.meta.allChallengesCount = meta.allChallengesCount
224-
+ data.length - meta.openChallengesCount;
225-
}
226220
}
227221
break;
228222
case BUCKETS.ONGOING: {
@@ -242,14 +236,7 @@ function onGetActiveChallengesDone(state, { error, payload }) {
242236
otherState.allOnGoingChallengesLoaded = checkAllLoaded(state.challenges,
243237
bucket, loaded, data);
244238
otherState.gettingMoreOnGoingChallenges = !otherState.allOnGoingChallengesLoaded;
245-
/* TODO Due to the meta of backend response is currently not correct,
246-
/* so should update counts after fetch all challenges of bucket */
247239
otherState.meta = _.clone(meta);
248-
if (_.get(meta, 'ongoingChallengesCount') !== data.length && otherState.allOnGoingChallengesLoaded) {
249-
otherState.meta.ongoingChallengesCount = data.length;
250-
otherState.meta.allChallengesCount = meta.allChallengesCount
251-
+ data.length - meta.ongoingChallengesCount;
252-
}
253240
}
254241
break;
255242
default:

0 commit comments

Comments
 (0)