Skip to content

Node.js based forum software built for the modern web

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

Barış Soner Uşaklı9839346ec36a
diff --git a/public/src/client/flags/list.js b/public/src/client/flags/list.js
index 870d6d4ff4..9c5dc63976 100644
--- a/public/src/client/flags/list.js
+++ b/public/src/client/flags/list.js
@@ -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'));
});
};
diff --git a/src/controllers/mods.js b/src/controllers/mods.js
index ddcd695ccc..d3f216322b 100644
--- a/src/controllers/mods.js
+++ b/src/controllers/mods.js
@@ -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 || [],
}));
};