File tree Expand file tree Collapse file tree 2 files changed +23
-9
lines changed Expand file tree Collapse file tree 2 files changed +23
-9
lines changed Original file line number Diff line number Diff line change @@ -68,11 +68,16 @@ const serialize = filter => filter.getURLEncoded();
68
68
69
69
70
70
// helper function to de-serialize query string to filter object
71
- const deserialize = queryString => new SideBarFilter ( {
72
- filter : queryString ,
73
- isSavedFilter : true , // So that we can reuse constructor for deserializing
74
- isCustomFilter : true ,
75
- } ) ;
71
+ const deserialize = queryString => {
72
+ const filter = new SideBarFilter ( {
73
+ filter : queryString ,
74
+ isSavedFilter : true , // So that we can reuse constructor for deserializing
75
+ } ) ;
76
+ if ( ! _ . values ( SideBarFilterModes ) . includes ( filter . name ) ) {
77
+ filter . isCustomFilter = true ;
78
+ }
79
+ return filter ;
80
+ }
76
81
77
82
// The demo component itself.
78
83
class ChallengeFiltersExample extends React . Component {
Original file line number Diff line number Diff line change @@ -104,10 +104,18 @@ class SideBarFilters extends React.Component {
104
104
// A fancy staff: if the parent has passed a filter, which does not exists
105
105
// (it is taken from a deep link), we add it to the list of filters and
106
106
// also select it.
107
- const f = new SideBarFilter ( props . filter ) ;
108
- f . count = props . challenges . filter ( f . getFilterFunction ( ) ) . length ;
109
- this . state . currentFilter = f ;
110
- this . state . filters . push ( f ) ;
107
+ // if the filter is one of the default filters then
108
+ // select it by default. We check on name and assume that
109
+ // a custom filter will never be named the same as a default filter.
110
+ if ( _ . values ( MODE ) . includes ( props . filter . name ) ) {
111
+ this . state . currentFilter = DEFAULT_FILTERS [ _ . values ( MODE ) . indexOf ( props . filter . name ) ]
112
+ }
113
+ else {
114
+ const f = new SideBarFilter ( props . filter ) ;
115
+ f . count = props . challenges . filter ( f . getFilterFunction ( ) ) . length ;
116
+ this . state . currentFilter = f ;
117
+ this . state . filters . push ( f ) ;
118
+ }
111
119
}
112
120
113
121
@@ -401,6 +409,7 @@ class SideBarFilters extends React.Component {
401
409
if ( currentFilter . mode === "Open for review" ) {
402
410
// Jump to Development Review Opportunities page
403
411
window . location . href = `${ this . props . config . MAIN_URL } /review/development-review-opportunities/` ;
412
+ return ;
404
413
}
405
414
this . setState ( { currentFilter } , ( ) => this . props . onFilter ( currentFilter ) ) ;
406
415
}
You can’t perform that action at this time.
0 commit comments