Skip to content

Commit

Permalink
fix: issue where the last flag filter could not be removed
Browse files Browse the repository at this point in the history
  • Loading branch information
julianlam committed Sep 23, 2020
1 parent abe8377 commit 0fffe28
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 1 addition & 3 deletions public/src/client/flags/list.js
Expand Up @@ -38,9 +38,7 @@ define('forum/flags/list', ['components', 'Chart'], function (components, Chart)
filtersEl.find('[name="sort"]').val(ajaxify.data.sort);

document.getElementById('apply-filters').addEventListener('click', function () {
var payload = filtersEl.serializeArray().filter(function (item) {
return !!item.value;
});
var payload = filtersEl.serializeArray();
ajaxify.go('flags?' + (payload.length ? $.param(payload) : 'reset=1'));
});
};
Expand Down
6 changes: 5 additions & 1 deletion src/controllers/mods.js
Expand Up @@ -47,7 +47,11 @@ modsController.flags.list = async function (req, res, next) {
// Parse query string params for filters, eliminate non-valid filters
filters = filters.reduce(function (memo, cur) {
if (req.query.hasOwnProperty(cur)) {
memo[cur] = req.query[cur];
if (req.query[cur] === '') {
delete req.session.flags_filters[cur];
} else {
memo[cur] = req.query[cur];
}
}

return memo;
Expand Down

0 comments on commit 0fffe28

Please sign in to comment.