From fd7ace5e0ac1845ff86872a84f1434b407215fc2 Mon Sep 17 00:00:00 2001 From: sr_jr Date: Sat, 6 Jun 2020 15:19:01 +0530 Subject: [PATCH 1/4] fix for issue #4384 --- src/shared/actions/challenge-listing/index.js | 11 ++--------- .../components/challenge-listing/Listing/index.jsx | 2 +- src/shared/containers/challenge-listing/Sidebar.jsx | 2 +- src/shared/utils/challenge-listing/buckets.js | 7 +++---- 4 files changed, 7 insertions(+), 15 deletions(-) diff --git a/src/shared/actions/challenge-listing/index.js b/src/shared/actions/challenge-listing/index.js index 080f77250b..5d3f9309fc 100644 --- a/src/shared/actions/challenge-listing/index.js +++ b/src/shared/actions/challenge-listing/index.js @@ -95,22 +95,15 @@ function getAllActiveChallengesWithUsersDone(uuid, tokenV3, filter, page = 0) { let user; if (tokenV3) { user = decodeToken(tokenV3).userId; - - const newFilter = _.mapKeys(filter, (value, key) => { - if (key === 'tag') return 'technologies'; - - return key; - }); - // Handle any errors on this endpoint so that the non-user specific challenges // will still be loaded. - calls.push(getAll(params => service.getUserChallenges(user, newFilter, params) - .catch(() => ({ challenges: [] }))), page); + calls.push(getAll(service.getUserChallenges(user).catch(() => ({ challenges: [] }))), page); } return Promise.all(calls).then(([ch, uch]) => { /* uch array contains challenges where the user is participating in @@ -111,8 +124,8 @@ function getAllActiveChallengesDone(uuid, tokenV3) { * challenges in an efficient way. */ + if (uch) { const map = {}; uch.forEach((item) => { map[item.id] = item; }); diff --git a/src/shared/components/challenge-listing/Listing/index.jsx b/src/shared/components/challenge-listing/Listing/index.jsx index 03af02573b..eb5fb6ee0f 100644 --- a/src/shared/components/challenge-listing/Listing/index.jsx +++ b/src/shared/components/challenge-listing/Listing/index.jsx @@ -45,7 +45,7 @@ function Listing({ expandTag, pastSearchTimestamp, }) { - const buckets = getBuckets(_.get(auth.user, 'handle')); + const buckets = getBuckets(_.get(auth.user, 'userId')); const isChallengesAvailable = (bucket) => { const filter = Filter.getFilterFunction(buckets[bucket].filter); const clonedChallenges = _.clone(challenges); diff --git a/src/shared/containers/challenge-listing/Sidebar.jsx b/src/shared/containers/challenge-listing/Sidebar.jsx index 8080d94b78..114b1cc0ae 100644 --- a/src/shared/containers/challenge-listing/Sidebar.jsx +++ b/src/shared/containers/challenge-listing/Sidebar.jsx @@ -62,7 +62,7 @@ export class SidebarContainer extends React.Component { user, } = this.props; - const buckets = getBuckets(user && user.handle); + const buckets = getBuckets(user && user.userId); if (extraBucket) { buckets[extraBucket.name] = extraBucket; diff --git a/src/shared/utils/challenge-listing/buckets.js b/src/shared/utils/challenge-listing/buckets.js index 3b1f3d74b0..1e73e28d7f 100644 --- a/src/shared/utils/challenge-listing/buckets.js +++ b/src/shared/utils/challenge-listing/buckets.js @@ -132,13 +132,12 @@ export const NO_LIVE_CHALLENGES_CONFIG = { /** * Returns configuration of all possible challenge buckets. - * @param {String} userHandle Handle of the authenticated + * @param {String} userId id of the authenticated * user to filter out My Challenges. */ -export function getBuckets(userHandle) { +export function getBuckets(userId) { const res = _.cloneDeep(BUCKET_DATA); - // TODO: Find equivalent of users - res[BUCKETS.MY].filter.users = [userHandle]; + res[BUCKETS.MY].filter.users = [userId]; return res; } From 620e9719b44400b93debbcd4d7b335cb7b907017 Mon Sep 17 00:00:00 2001 From: sr_jr Date: Sun, 7 Jun 2020 09:58:30 +0530 Subject: [PATCH 2/4] fix for issue #4384 --- src/shared/actions/challenge-listing/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/shared/actions/challenge-listing/index.js b/src/shared/actions/challenge-listing/index.js index 5d3f9309fc..760d6321d9 100644 --- a/src/shared/actions/challenge-listing/index.js +++ b/src/shared/actions/challenge-listing/index.js @@ -97,7 +97,8 @@ function getAllActiveChallengesWithUsersDone(uuid, tokenV3, filter, page = 0) { user = decodeToken(tokenV3).userId; // Handle any errors on this endpoint so that the non-user specific challenges // will still be loaded. - calls.push(getAll(service.getUserChallenges(user).catch(() => ({ challenges: [] }))), page); + calls.push(getAll(params => service.getUserChallenges(user, filter, params) + .catch(() => ({ challenges: [] }))), page); } return Promise.all(calls).then(([ch, uch]) => { /* uch array contains challenges where the user is participating in From bfe04b774e5d73109efb8136c5026e9f23178b74 Mon Sep 17 00:00:00 2001 From: sr_jr Date: Sun, 7 Jun 2020 10:03:15 +0530 Subject: [PATCH 3/4] fix for issue #4384 --- src/shared/actions/challenge-listing/index.js | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/shared/actions/challenge-listing/index.js b/src/shared/actions/challenge-listing/index.js index 760d6321d9..6a45933436 100644 --- a/src/shared/actions/challenge-listing/index.js +++ b/src/shared/actions/challenge-listing/index.js @@ -95,9 +95,16 @@ function getAllActiveChallengesWithUsersDone(uuid, tokenV3, filter, page = 0) { let user; if (tokenV3) { user = decodeToken(tokenV3).userId; + + const newFilter = _.mapKeys(filter, (value, key) => { + if (key === 'tag') return 'technologies'; + + return key; + }); + // Handle any errors on this endpoint so that the non-user specific challenges // will still be loaded. - calls.push(getAll(params => service.getUserChallenges(user, filter, params) + calls.push(getAll(params => service.getUserChallenges(user, newFilter, params) .catch(() => ({ challenges: [] }))), page); } return Promise.all(calls).then(([ch, uch]) => { From 5811f08cc418b38378fa8725507b3089126cfb18 Mon Sep 17 00:00:00 2001 From: sr_jr Date: Sun, 7 Jun 2020 10:03:40 +0530 Subject: [PATCH 4/4] fix for issue #4384 --- src/shared/actions/challenge-listing/index.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/shared/actions/challenge-listing/index.js b/src/shared/actions/challenge-listing/index.js index 6a45933436..080f77250b 100644 --- a/src/shared/actions/challenge-listing/index.js +++ b/src/shared/actions/challenge-listing/index.js @@ -111,7 +111,6 @@ function getAllActiveChallengesWithUsersDone(uuid, tokenV3, filter, page = 0) { /* uch array contains challenges where the user is participating in @@ -111,8 +124,8 @@ function getAllActiveChallengesDone(uuid, tokenV3) { * challenges in an efficient way. */ - if (uch) { const map = {}; uch.forEach((item) => { map[item.id] = item; });