Skip to content

A platform for community discussion. Free, open, simple.

FIX: prevents false boolean param to be filtered as non existant (#9968)

Joffrey JAFFEUXd27b877a4033
diff --git a/app/assets/javascripts/discourse/app/routes/build-category-route.js b/app/assets/javascripts/discourse/app/routes/build-category-route.js
index 18fe88124f0..eac84d84849 100644
--- a/app/assets/javascripts/discourse/app/routes/build-category-route.js
+++ b/app/assets/javascripts/discourse/app/routes/build-category-route.js
@@ -61,12 +61,12 @@ export default (filterArg, params) => {
const record = this.store.createRecord("category", result.category);
record.setupGroupsAndPermissions();
this.site.updateCategory(record);
- return { category: record };
+ return { category: record, modelParams };
});
}
if (category) {
- return { category };
+ return { category, modelParams };
}
},
@@ -79,7 +79,7 @@ export default (filterArg, params) => {
this._setupNavigation(model.category);
return all([
this._createSubcategoryList(model.category),
- this._retrieveTopicList(model.category, transition)
+ this._retrieveTopicList(model.category, transition, model.modelParams)
]);
},
@@ -113,11 +113,11 @@ export default (filterArg, params) => {
return Promise.resolve();
},
- _retrieveTopicList(category, transition) {
+ _retrieveTopicList(category, transition, modelParams) {
const listFilter = `c/${Category.slugFor(category)}/${
category.id
}/l/${this.filter(category)}`,
- findOpts = filterQueryParams(transition.to.queryParams, params),
+ findOpts = filterQueryParams(modelParams),
extras = { cached: this.isPoppedState(transition) };
return findTopicList(
diff --git a/app/assets/javascripts/discourse/app/routes/build-topic-route.js b/app/assets/javascripts/discourse/app/routes/build-topic-route.js
index 8d34c8380e5..786e9d557f9 100644
--- a/app/assets/javascripts/discourse/app/routes/build-topic-route.js
+++ b/app/assets/javascripts/discourse/app/routes/build-topic-route.js
@@ -1,3 +1,4 @@
+import { isEmpty } from "@ember/utils";
import I18n from "I18n";
import DiscourseRoute from "discourse/routes/discourse";
import { queryParams } from "discourse/controllers/discovery-sortable";
@@ -12,7 +13,7 @@ function filterQueryParams(params, defaultParams) {
if (params) {
Object.keys(queryParams).forEach(function(opt) {
- if (params[opt]) {
+ if (!isEmpty(params[opt])) {
findOpts[opt] = params[opt];
}
});
@@ -50,10 +51,12 @@ function findTopicList(store, tracking, filter, filterParams, extras) {
// Clean up any string parameters that might slip through
filterParams = filterParams || {};
- Object.keys(filterParams).forEach(function(k) {
- const val = filterParams[k];
- if (val === "undefined" || val === "null" || val === "false") {
- filterParams[k] = undefined;
+ Object.keys(filterParams).forEach(k => {
+ let val = filterParams[k];
+ if (val === "false") val = false;
+ if (val === "true") val = true;
+ if (val === "undefined" || val === "null") {
+ filterParams[k] = null;
}
});