From 12913a46e4e6612042e88e67451ceef460da7954 Mon Sep 17 00:00:00 2001 From: Bianca Nenciu Date: Mon, 3 Aug 2020 11:19:36 +0300 Subject: [PATCH] FIX: Reset max_posts query parameter (#10334) --- .../app/routes/build-category-route.js | 20 ++++++++++++++++++- .../discourse/app/routes/build-topic-route.js | 20 ++++++++++++++++++- 2 files changed, 38 insertions(+), 2 deletions(-) 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 a28b6c84710..aab3d9c039a 100644 --- a/app/assets/javascripts/discourse/app/routes/build-category-route.js +++ b/app/assets/javascripts/discourse/app/routes/build-category-route.js @@ -10,6 +10,7 @@ import PermissionType from "discourse/models/permission-type"; import CategoryList from "discourse/models/category-list"; import Category from "discourse/models/category"; import { Promise, all } from "rsvp"; +import { action } from "@ember/object"; // A helper function to create a category route with parameters export default (filterArg, params) => { @@ -229,9 +230,26 @@ export default (filterArg, params) => { }); }, + resetParams(controller) { + controller.setProperties({ + order: "default", + ascending: false, + max_posts: null + }); + }, + + @action + willTransition() { + this._super(...arguments); + + if (this.controller) { + this.resetParams(this.controller); + } + }, + resetController(controller, isExiting) { if (isExiting) { - controller.setProperties({ order: "default", ascending: false }); + this.resetParams(controller); } }, 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 f623bf0b5c3..cfa069fed0c 100644 --- a/app/assets/javascripts/discourse/app/routes/build-topic-route.js +++ b/app/assets/javascripts/discourse/app/routes/build-topic-route.js @@ -6,6 +6,7 @@ import { defaultHomepage } from "discourse/lib/utilities"; import Session from "discourse/models/session"; import { Promise } from "rsvp"; import Site from "discourse/models/site"; +import { action } from "@ember/object"; // A helper to build a topic route for a filter function filterQueryParams(params, defaultParams) { @@ -147,9 +148,26 @@ export default function(filter, extras) { ); }, + resetParams(controller) { + controller.setProperties({ + order: "default", + ascending: false, + max_posts: null + }); + }, + + @action + willTransition() { + this._super(...arguments); + + if (this.controller) { + this.resetParams(this.controller); + } + }, + resetController(controller, isExiting) { if (isExiting) { - controller.setProperties({ order: "default", ascending: false }); + this.resetParams(controller); } },