From ea9c3e35d157de6d7cd430da607896ffc5601568 Mon Sep 17 00:00:00 2001 From: Huan Li Date: Fri, 24 May 2019 11:56:48 +0800 Subject: [PATCH 1/2] Fixed issues of server-side filtering on challenge listings --- src/actions/challenge-listing.js | 30 +++++++++++++++++------------- src/reducers/challenge-listing.js | 23 ++++++++++++++++++----- 2 files changed, 35 insertions(+), 18 deletions(-) diff --git a/src/actions/challenge-listing.js b/src/actions/challenge-listing.js index 2e9c0d08..e60f10f0 100644 --- a/src/actions/challenge-listing.js +++ b/src/actions/challenge-listing.js @@ -150,7 +150,11 @@ function getAllActiveChallengesDone(uuid, tokenV3) { }); } - return { uuid, challenges: ch.challenges }; + return { + uuid, + challenges: ch.challenges, + handle: user, + }; }); } @@ -197,27 +201,27 @@ function getActiveChallengesDone( }).catch(() => ({ challenges: [] }))); } return Promise.all(calls).then(([ch, uch]) => { - let fullCH = ch; + // let fullCH = ch; /* uch array contains challenges where the user is participating in * some role. The same challenge are already listed in res array, but they * are not attributed to the user there. This block of code marks user * challenges in an efficient way. */ if (uch) { const map = {}; - uch.challenges.forEach((item) => { - map[item.id] = item; - /* eslint-disable no-param-reassign */ - item.users[user] = true; - item.userDetails = map[item.id].userDetails; - /* eslint-enable no-param-reassign */ + uch.challenges.forEach((item) => { map[item.id] = item; }); + ch.challenges.forEach((item) => { + if (map[item.id]) { + /* It is fine to reassing, as the array we modifying is created just + * above within the same function. */ + /* eslint-disable no-param-reassign */ + item.users[user] = true; + item.userDetails = map[item.id].userDetails; + /* eslint-enable no-param-reassign */ + } }); } - if (uch) { - fullCH = uch; - } - let { challenges } = fullCH; - let { meta } = ch; + let { challenges, meta } = ch; // filter by date range and re-compute meta // we can safely remove the next two lines when backend support date range challenges = filterUtil.filterByDate(challenges, frontFilter); diff --git a/src/reducers/challenge-listing.js b/src/reducers/challenge-listing.js index b1d87967..10d359c7 100644 --- a/src/reducers/challenge-listing.js +++ b/src/reducers/challenge-listing.js @@ -94,20 +94,33 @@ function onGetAllActiveChallengesDone(state, { error, payload }) { logger.error(payload); return state; } - const { uuid, challenges: loaded } = payload; + const { + uuid, challenges: loaded, handle, + } = payload; if (uuid !== state.loadingActiveChallengesUUID) return state; /* Once all active challenges are fetched from the API, we remove from the * store any active challenges stored there previously, and also any * challenges with IDs matching any challenges loaded now as active. */ const ids = new Set(); loaded.forEach(item => ids.add(item.id)); - const challenges = state.challenges - .filter(item => item.status !== 'ACTIVE' && !ids.has(item.id)) - .concat(loaded); + + const filter = item => !ids.has(item.id) && item.status !== 'ACTIVE'; + // BUCKET.MY + const my = processBucketData( + handle, state.challenges, loaded, BUCKETS.MY, null, null, filter, {}, + ); + // BUCKET.ALL + const all = processBucketData( + handle, state.challenges, loaded, BUCKETS.ALL, null, null, filter, {}, + ); + + const newChallenges = _.cloneDeep(state.challenges); + newChallenges[BUCKETS.ALL] = all; + newChallenges[BUCKETS.MY] = my; return { ...state, - challenges, + challenges: newChallenges, lastUpdateOfActiveChallenges: Date.now(), loadingActiveChallengesUUID: '', }; From 3a520fff5b8aa633c0a2f1d23f21adc83bb7c0f2 Mon Sep 17 00:00:00 2001 From: Sushil Shinde Date: Mon, 27 May 2019 16:20:44 +0530 Subject: [PATCH 2/2] Updating NPM version for prod release to 0.7.15 Updating NPM version for prod release to 0.7.15 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index d0fa7e8c..a8163f0b 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "lint:js": "./node_modules/.bin/eslint --ext .js,.jsx .", "test": "npm run lint && npm run jest" }, - "version": "0.7.14", + "version": "0.7.15", "dependencies": { "auth0-js": "^6.8.4", "isomorphic-fetch": "^2.2.1", pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy