From 1137761d3ef93003f257dc1ec46ed37bec2c36e2 Mon Sep 17 00:00:00 2001 From: yoution Date: Sat, 19 Oct 2019 01:04:07 +0800 Subject: [PATCH] Topcoder Community-App: Challenges Filter and Stats - Part 3 --- .../containers/challenge-listing/FilterPanel.jsx | 16 ++++++++++++++++ .../challenge-listing/Listing/index.jsx | 6 +++++- .../containers/challenge-listing/Sidebar.jsx | 8 +++++++- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/shared/containers/challenge-listing/FilterPanel.jsx b/src/shared/containers/challenge-listing/FilterPanel.jsx index a9a3ccba01..b62194d072 100644 --- a/src/shared/containers/challenge-listing/FilterPanel.jsx +++ b/src/shared/containers/challenge-listing/FilterPanel.jsx @@ -2,6 +2,7 @@ * Container for the header filters panel. */ /* global window */ +/* eslint-disable max-len */ import actions from 'actions/challenge-listing/filter-panel'; import challengeListingActions from 'actions/challenge-listing'; @@ -66,6 +67,20 @@ export class Container extends React.Component { } } + componentWillUpdate(nextProps) { + const { + selectCommunity, + communityFilters, + } = this.props; + + if (nextProps.communityFilters.length > 0 && communityFilters.length === 0) { + const query = qs.parse(window.location.search.slice(1)); + if (query.communityId) { + selectCommunity(query.communityId); + } + } + } + render() { const { activeBucket, @@ -144,6 +159,7 @@ Container.propTypes = { selectedCommunityId: PT.string.isRequired, getKeywords: PT.func.isRequired, getSubtracks: PT.func.isRequired, + selectCommunity: PT.func.isRequired, isSavingFilter: PT.bool, savedFilters: PT.arrayOf(PT.shape()).isRequired, loadingKeywords: PT.bool.isRequired, diff --git a/src/shared/containers/challenge-listing/Listing/index.jsx b/src/shared/containers/challenge-listing/Listing/index.jsx index 5baedb9510..d6394b3c7a 100644 --- a/src/shared/containers/challenge-listing/Listing/index.jsx +++ b/src/shared/containers/challenge-listing/Listing/index.jsx @@ -218,8 +218,12 @@ export class ListingContainer extends React.Component { ); } + let isTrueCommunityId = true; let communityFilter = communityFilters.find(item => item.communityId === selectedCommunityId); if (communityFilter) communityFilter = communityFilter.challengeFilter; + if (selectedCommunityId && communityFilters.length > 0 && communityFilter === undefined) { + isTrueCommunityId = false; + } const description = 'Join Topcoder and compete in these challenges, to learn and earn!'; @@ -252,7 +256,7 @@ export class ListingContainer extends React.Component { {banner} item.communityId === selectedCommunityId, ); if (communityFilter) communityFilter = communityFilter.challengeFilter; - + let isTrueCommunityId = true; + if (selectedCommunityId && communityFilters.length > 0 && communityFilter === undefined) { + isTrueCommunityId = false; + } const savedFilters = checkFilterErrors(origSavedFilters, updatedCommunityFilters); return ( @@ -88,6 +92,7 @@ export class SidebarContainer extends React.Component { {...this.props} buckets={buckets} extraBucket={extraBucket} + challenges={isTrueCommunityId ? challenges : []} savedFilters={savedFilters} communityFilter={communityFilter} deleteSavedFilter={id => deleteSavedFilter(id, tokenV2)} @@ -122,6 +127,7 @@ SidebarContainer.propTypes = { communityId: PT.string.isRequired, })).isRequired, deleteSavedFilter: PT.func.isRequired, + challenges: PT.arrayOf(PT.shape({})).isRequired, extraBucket: PT.shape(), getSavedFilters: PT.func.isRequired, savedFilters: PT.arrayOf(PT.shape()).isRequired,