Skip to content

Fix issue #187 #327

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 1, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 23 additions & 3 deletions src/shared/reducers/challenge-listing/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,20 @@ function onSelectCommunity(state, { payload }) {
* @return {Object}
*/
function onSetFilter(state, { payload }) {
updateQuery({ filter: payload });
const filter = _.clone(payload);

if (filter) {
if (filter.tags && !_.isArray(filter.tags)) {
filter.tags = _.values(filter.tags);
}
if (filter.subtracks && !_.isArray(filter.subtracks)) {
filter.subtracks = _.values(filter.subtracks);
}
}
updateQuery({ filter });
return {
...state,
filter: payload,
filter,

/* Page numbers of past/upcoming challenges depend on the filters. To keep
* the code simple we just reset them each time a filter is modified. */
Expand Down Expand Up @@ -272,7 +282,17 @@ export function factory(req) {
const state = {};

if (req) {
state.filter = req.query.filter;
let filter = {};
if (req.query && req.query.filter) {
filter = _.clone(req.query.filter);
if (filter.tags && !_.isArray(filter.tags)) {
filter.tags = _.values(filter.tags);
}
if (filter.subtracks && !_.isArray(filter.subtracks)) {
filter.subtracks = _.values(filter.subtracks);
}
}
state.filter = filter;

/* TODO: OK, fine, this validation of dates does the server-side part of
* the trick, while the frontend part (removing them from URL) is done
Expand Down