@@ -132,6 +132,8 @@ class ChallengeFiltersExample extends React.Component {
132
132
. then ( ( json ) => {
133
133
json . result . content . forEach ( item => VALID_KEYWORDS . push ( keywordsMapper ( item . name ) ) ) ;
134
134
} ) ;
135
+ // callback to listings.controller.js
136
+ props . setChallengeFilter ( this ) ;
135
137
}
136
138
137
139
/**
@@ -309,6 +311,22 @@ class ChallengeFiltersExample extends React.Component {
309
311
this . setState ( { filter : updatedFilter } , this . saveFiltersToHash . bind ( this , updatedFilter ) ) ;
310
312
}
311
313
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
+
312
330
// ReactJS render method.
313
331
render ( ) {
314
332
// TODO: This is bad code. Generation of myChallengesId array is O(N),
@@ -532,6 +550,7 @@ ChallengeFiltersExample.defaultProps = {
532
550
} ,
533
551
filterFromUrl : '' ,
534
552
onSaveFilterToUrl : _ . noop ,
553
+ setChallengeFilter : _ . noop ,
535
554
myChallenges : [ ] ,
536
555
challengeFilters : undefined ,
537
556
isAuth : false ,
@@ -544,6 +563,7 @@ ChallengeFiltersExample.propTypes = {
544
563
} ) ,
545
564
filterFromUrl : PT . string ,
546
565
onSaveFilterToUrl : PT . func ,
566
+ setChallengeFilter : PT . func ,
547
567
myChallenges : PT . array ,
548
568
challengeFilters : PT . object ,
549
569
isAuth : PT . bool ,
0 commit comments