FIX: Reset max_posts query parameter (#10334)

FIX: Reset max_posts query parameter (#10334)

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 a28b6c8..aab3d9c 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 f623bf0..cfa069f 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);
         }
       },
 

GitHub sha: 12913a46

This commit appears in #10334 which was approved by eviltrout. It was merged by nbianca.