Skip to content

Commit 9396320

Browse files
authored
Merge pull request #214 from chq-matteo/patch-6
Fix #1168
2 parents 0cdd360 + 3f1b50e commit 9396320

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

components/ChallengeFilters/ChallengeFiltersExample.jsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,8 @@ class ChallengeFiltersExample extends React.Component {
132132
.then((json) => {
133133
json.result.content.forEach(item => VALID_KEYWORDS.push(keywordsMapper(item.name)));
134134
});
135+
// callback to listings.controller.js
136+
props.setChallengeFilter(this);
135137
}
136138

137139
/**
@@ -309,6 +311,22 @@ class ChallengeFiltersExample extends React.Component {
309311
this.setState({ filter: updatedFilter }, this.saveFiltersToHash.bind(this, updatedFilter));
310312
}
311313

314+
updateFilter(hash) {
315+
// get the latest filter and update current challenges
316+
this.state = {
317+
challenges: [],
318+
srmChallenges: [],
319+
currentCardType: 'Challenges',
320+
filter: new SideBarFilter(),
321+
lastFetchId: 0,
322+
};
323+
if (hash) {
324+
this.state.filter = deserialize(hash);
325+
this.state.searchQuery = hash.split('&').filter(e => e.startsWith('query')).map(element => element.split('=')[1])[0];
326+
}
327+
this.fetchChallenges(0).then(res => this.setChallenges(0, res));
328+
}
329+
312330
// ReactJS render method.
313331
render() {
314332
// TODO: This is bad code. Generation of myChallengesId array is O(N),
@@ -532,6 +550,7 @@ ChallengeFiltersExample.defaultProps = {
532550
},
533551
filterFromUrl: '',
534552
onSaveFilterToUrl: _.noop,
553+
setChallengeFilter: _.noop,
535554
myChallenges: [],
536555
challengeFilters: undefined,
537556
isAuth: false,
@@ -544,6 +563,7 @@ ChallengeFiltersExample.propTypes = {
544563
}),
545564
filterFromUrl: PT.string,
546565
onSaveFilterToUrl: PT.func,
566+
setChallengeFilter: PT.func,
547567
myChallenges: PT.array,
548568
challengeFilters: PT.object,
549569
isAuth: PT.bool,

0 commit comments

Comments
 (0)