Skip to content

Commit 72cbc0e

Browse files
authored
Merge pull request #2399 from suppermancool/issue-2381-2
Challenge Listing Page: Sub community dropdown has only one value #2381
2 parents 1ce7438 + eb6c0e7 commit 72cbc0e

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/shared/containers/challenge-listing/FilterPanel.jsx

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55

66
import actions from 'actions/challenge-listing/filter-panel';
77
import challengeListingActions from 'actions/challenge-listing';
8+
import communityActions from 'actions/tc-communities';
9+
import shortId from 'shortid';
810
import FilterPanel from 'components/challenge-listing/Filters/ChallengeFilters';
911
import PT from 'prop-types';
1012
import React from 'react';
@@ -18,6 +20,7 @@ import qs from 'qs';
1820
* number will be appended to it, when necessary, to keep filter
1921
* names unique. */
2022
const DEFAULT_SAVED_FILTER_NAME = 'My Filter';
23+
const MIN = 60 * 1000;
2124

2225
/**
2326
* Returns a vacant name for the user saved filter.
@@ -44,7 +47,15 @@ export class Container extends React.Component {
4447
loadingSubtracks,
4548
setFilterState,
4649
filterState,
50+
communityList,
51+
getCommunityList,
52+
auth,
4753
} = this.props;
54+
55+
if (communityList && !communityList.loadingUuid
56+
&& (Date.now() - communityList.timestamp > 5 * MIN)) {
57+
getCommunityList(auth);
58+
}
4859
if (!loadingSubtracks) getSubtracks();
4960
if (!loadingKeywords) getKeywords();
5061

@@ -119,6 +130,15 @@ Container.propTypes = {
119130
activeBucket: PT.string.isRequired,
120131
communityFilters: PT.arrayOf(PT.object).isRequired,
121132
defaultCommunityId: PT.string.isRequired,
133+
getCommunityList: PT.func.isRequired,
134+
communityList: PT.shape({
135+
data: PT.arrayOf(PT.shape({
136+
communityId: PT.string.isRequired,
137+
communityName: PT.string.isRequired,
138+
})).isRequired,
139+
loadingUuid: PT.string.isRequired,
140+
timestamp: PT.number.isRequired,
141+
}).isRequired,
122142
filterState: PT.shape().isRequired,
123143
challenges: PT.arrayOf(PT.shape()),
124144
selectedCommunityId: PT.string.isRequired,
@@ -145,6 +165,11 @@ function mapDispatchToProps(dispatch) {
145165
dispatch(cla.getChallengeSubtracksInit());
146166
dispatch(cla.getChallengeSubtracksDone());
147167
},
168+
getCommunityList: (auth) => {
169+
const uuid = shortId();
170+
dispatch(communityActions.tcCommunity.getListInit(uuid));
171+
dispatch(communityActions.tcCommunity.getListDone(uuid, auth));
172+
},
148173
getKeywords: () => {
149174
dispatch(cla.getChallengeTagsInit());
150175
dispatch(cla.getChallengeTagsDone());
@@ -167,6 +192,7 @@ function mapStateToProps(state, ownProps) {
167192
...state.challengeListing.filterPanel,
168193
activeBucket: cl.sidebar.activeBucket,
169194
communityFilters: tc.list.data,
195+
communityList: tc.list,
170196
defaultCommunityId: ownProps.defaultCommunityId,
171197
filterState: cl.filter,
172198
loadingKeywords: cl.loadingChallengeTags,

0 commit comments

Comments
 (0)