From 9839346ec36aadc4cb265caba77b70e60dc83956 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bar=C4=B1=C5=9F=20Soner=20U=C5=9Fakl=C4=B1?= Date: Sun, 3 May 2020 14:48:15 -0400 Subject: [PATCH] fix: #8290, if there are no filters go to ?reset=1 dont count ?page=1 as a filter --- public/src/client/flags/list.js | 2 +- src/controllers/mods.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) 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 || [], })); };