REFACTOR: `filterBy` in `UserStream`.

REFACTOR: filterBy in UserStream.

Follow up to ebe65577ed33f0d44c82380b194dbd13398e5237.

diff --git a/app/assets/javascripts/discourse/models/user-stream.js.es6 b/app/assets/javascripts/discourse/models/user-stream.js.es6
index 891b7f9..bca6e7c 100644
--- a/app/assets/javascripts/discourse/models/user-stream.js.es6
+++ b/app/assets/javascripts/discourse/models/user-stream.js.es6
@@ -30,15 +30,17 @@ export default RestModel.extend({
     "/user_actions.json?offset=%@&username=%@"
   ),
 
-  filterBy(filter, noContentHelpKey, actingUsername) {
-    this.setProperties({
-      filter,
-      itemsLoaded: 0,
-      content: [],
-      noContentHelpKey,
-      lastLoadedUrl: null,
-      actingUsername
-    });
+  filterBy(opts) {
+    this.setProperties(
+      Object.assign(
+        {
+          itemsLoaded: 0,
+          content: [],
+          lastLoadedUrl: null
+        },
+        opts
+      )
+    );
 
     return this.findItems();
   },
diff --git a/app/assets/javascripts/discourse/routes/build-admin-user-posts-route.js.es6 b/app/assets/javascripts/discourse/routes/build-admin-user-posts-route.js.es6
index a020d72..bc80113 100644
--- a/app/assets/javascripts/discourse/routes/build-admin-user-posts-route.js.es6
+++ b/app/assets/javascripts/discourse/routes/build-admin-user-posts-route.js.es6
@@ -14,10 +14,8 @@ export default function(filter) {
       return this.modelFor("user").get("postsStream");
     },
 
-    afterModel() {
-      return this.modelFor("user")
-        .get("postsStream")
-        .filterBy(filter);
+    afterModel(model) {
+      return model.filterBy({ filter });
     },
 
     setupController(controller, model) {
diff --git a/app/assets/javascripts/discourse/routes/user-activity-stream.js.es6 b/app/assets/javascripts/discourse/routes/user-activity-stream.js.es6
index 4ba462e..e106290 100644
--- a/app/assets/javascripts/discourse/routes/user-activity-stream.js.es6
+++ b/app/assets/javascripts/discourse/routes/user-activity-stream.js.es6
@@ -10,11 +10,12 @@ export default Discourse.Route.extend(ViewingActionType, {
   },
 
   afterModel(model, transition) {
-    return model.filterBy(
-      this.get("userActionType"),
-      this.get("noContentHelpKey") || "user_activity.no_default",
-      transition.queryParams.acting_username
-    );
+    return model.filterBy({
+      filter: this.get("userActionType"),
+      noContentHelpKey:
+        this.get("noContentHelpKey") || "user_activity.no_default",
+      actingUsername: transition.queryParams.acting_username
+    });
   },
 
   renderTemplate() {

GitHub sha: 40533bc5

1 Like

Thanks for doing this! :+1: