fix: #8290, if there are no filters go to ?reset=1

dont count ?page=1 as a filter
This commit is contained in:
Barış Soner Uşaklı
2020-05-03 14:48:15 -04:00
parent 2cf0a9b62d
commit 9839346ec3
2 changed files with 6 additions and 2 deletions

View File

@@ -23,7 +23,7 @@ define('forum/flags/list', ['components', 'Chart'], function (components, Chart)
var payload = filtersEl.serializeArray().filter(function (item) {
return !!item.value;
});
ajaxify.go('flags?' + $.param(payload));
ajaxify.go('flags?' + (payload.length ? $.param(payload) : 'reset=1'));
});
};

View File

@@ -66,7 +66,10 @@ modsController.flags.list = async function (req, res, next) {
}
// Pagination doesn't count as a filter
if (Object.keys(filters).length === 2 && filters.hasOwnProperty('page') && filters.hasOwnProperty('perPage')) {
if (
(Object.keys(filters).length === 1 && filters.hasOwnProperty('page')) ||
(Object.keys(filters).length === 2 && filters.hasOwnProperty('page') && filters.hasOwnProperty('perPage'))
) {
hasFilter = false;
}
@@ -130,6 +133,7 @@ modsController.flags.detail = async function (req, res, next) {
}, {}),
title: '[[pages:flag-details, ' + req.params.flagId + ']]',
categories: results.categories,
filters: req.session.flags_filters || [],
}));
};