diff --git a/src/shared/containers/challenge-listing/Listing/index.jsx b/src/shared/containers/challenge-listing/Listing/index.jsx index e0c1610e0a..d92ec6cd27 100644 --- a/src/shared/containers/challenge-listing/Listing/index.jsx +++ b/src/shared/containers/challenge-listing/Listing/index.jsx @@ -112,6 +112,8 @@ export class ListingContainer extends React.Component { // activeBucket, auth, // dropChallenges, + communityId, + communitiesList, getCommunitiesList, // allActiveChallengesLoaded, // getRestActiveChallenges, @@ -134,6 +136,7 @@ export class ListingContainer extends React.Component { getPastChallenges, filterState, loading, + setFilter, } = this.props; const oldUserId = _.get(prevProps, 'auth.user.userId'); const userId = _.get(this.props, 'auth.user.userId'); @@ -177,6 +180,23 @@ export class ListingContainer extends React.Component { bucket = 'openForRegistration'; } + if (prevProps.communitiesList.data.length !== communitiesList.data.length) { + let selectedCommunity; + if (communityId) { + selectedCommunity = communitiesList.data.find(item => item.communityId === communityId); + } + if (selectedCommunity) { + const groups = selectedCommunity.groupIds && selectedCommunity.groupIds.length + ? [selectedCommunity.groupIds[0]] : []; + // update the challenge listing filter for selected community + setFilter({ + ..._.clone(filter), + groups, + events: [], + }); + } + } + if (bucket) { switch (bucket) { case BUCKETS.MY: { diff --git a/src/shared/routes/Communities/ChallengeListing.jsx b/src/shared/routes/Communities/ChallengeListing.jsx index 0e19ca64cc..015121f391 100644 --- a/src/shared/routes/Communities/ChallengeListing.jsx +++ b/src/shared/routes/Communities/ChallengeListing.jsx @@ -31,7 +31,8 @@ export default function ChallengeListingRoute({ let { communityId } = query; if (!communityId - && !_.get(meta, 'challengeListing.ignoreCommunityFilterByDefault')) { + && (!_.get(meta, 'challengeListing.ignoreCommunityFilterByDefault') + || meta.communityId === 'wipro')) { ({ communityId } = meta); }