remove ?page when changing filters

isekai-main
Barış Soner Uşaklı 2 years ago
parent f95929b258
commit 304f9b6eef

@ -52,6 +52,8 @@ define('categoryFilter', ['categorySearch', 'api', 'hooks'], function (categoryS
} else { } else {
delete currentParams.cid; delete currentParams.cid;
} }
delete currentParams.page;
if (Object.keys(currentParams).length) { if (Object.keys(currentParams).length) {
url += '?' + decodeURIComponent($.param(currentParams)); url += '?' + decodeURIComponent($.param(currentParams));
} }
@ -70,9 +72,6 @@ define('categoryFilter', ['categorySearch', 'api', 'hooks'], function (categoryS
const icon = categoryEl.find('[component="category/select/icon"]'); const icon = categoryEl.find('[component="category/select/icon"]');
if (cid !== 'all') { if (cid !== 'all') {
if (selectedCids.includes('all')) {
selectedCids.splice(selectedCids.indexOf('all'), 1);
}
if (selectedCids.includes(cid)) { if (selectedCids.includes(cid)) {
selectedCids.splice(selectedCids.indexOf(cid), 1); selectedCids.splice(selectedCids.indexOf(cid), 1);
} else { } else {
@ -83,13 +82,10 @@ define('categoryFilter', ['categorySearch', 'api', 'hooks'], function (categoryS
}); });
icon.toggleClass('invisible'); icon.toggleClass('invisible');
listEl.find('[data-cid="all"] i').toggleClass('invisible', !!selectedCids.length); listEl.find('[data-cid="all"] i').toggleClass('invisible', !!selectedCids.length);
if (!selectedCids.length) {
selectedCids.push('all');
}
} else { } else {
el.find('[component="category/select/icon"]').addClass('invisible'); el.find('[component="category/select/icon"]').addClass('invisible');
listEl.find('[data-cid="all"] i').removeClass('invisible'); listEl.find('[data-cid="all"] i').removeClass('invisible');
selectedCids = ['all']; selectedCids = [];
} }
options.selectedCids = selectedCids; options.selectedCids = selectedCids;

@ -101,6 +101,7 @@ define('tagFilter', ['hooks', 'alerts', 'bootstrap'], function (hooks, alerts, b
} else { } else {
delete currentParams.tag; delete currentParams.tag;
} }
delete currentParams.page;
if (Object.keys(currentParams).length) { if (Object.keys(currentParams).length) {
url += '?' + decodeURIComponent($.param(currentParams)); url += '?' + decodeURIComponent($.param(currentParams));
} }

@ -68,10 +68,12 @@ recentController.getData = async function (req, url, sort) {
data.breadcrumbs = helpers.buildBreadcrumbs([{ text: `[[${url}:title]]` }]); data.breadcrumbs = helpers.buildBreadcrumbs([{ text: `[[${url}:title]]` }]);
} }
const query = { ...req.query };
delete query.page;
data.canPost = canPost; data.canPost = canPost;
data.showSelect = isPrivileged; data.showSelect = isPrivileged;
data.showTopicTools = isPrivileged; data.showTopicTools = isPrivileged;
data.allCategoriesUrl = baseUrl + helpers.buildQueryString(req.query, 'cid', ''); data.allCategoriesUrl = baseUrl + helpers.buildQueryString(query, 'cid', '');
data.selectedCategory = categoryData.selectedCategory; data.selectedCategory = categoryData.selectedCategory;
data.selectedCids = categoryData.selectedCids; data.selectedCids = categoryData.selectedCids;
data.selectedTag = tagData.selectedTag; data.selectedTag = tagData.selectedTag;
@ -82,9 +84,9 @@ recentController.getData = async function (req, url, sort) {
data.rssFeedUrl += `?uid=${req.uid}&token=${rssToken}`; data.rssFeedUrl += `?uid=${req.uid}&token=${rssToken}`;
} }
data.filters = helpers.buildFilters(baseUrl, filter, req.query); data.filters = helpers.buildFilters(baseUrl, filter, query);
data.selectedFilter = data.filters.find(filter => filter && filter.selected); data.selectedFilter = data.filters.find(filter => filter && filter.selected);
data.terms = helpers.buildTerms(baseUrl, term, req.query); data.terms = helpers.buildTerms(baseUrl, term, query);
data.selectedTerm = data.terms.find(term => term && term.selected); data.selectedTerm = data.terms.find(term => term && term.selected);
const pageCount = Math.max(1, Math.ceil(data.topicCount / settings.topicsPerPage)); const pageCount = Math.max(1, Math.ceil(data.topicCount / settings.topicsPerPage));

Loading…
Cancel
Save