REFACTOR: user-posts-stream model (#7657)

REFACTOR: user-posts-stream model (#7657)

diff --git a/app/assets/javascripts/discourse/models/user-posts-stream.js.es6 b/app/assets/javascripts/discourse/models/user-posts-stream.js.es6
index a106b28..7521b82 100644
--- a/app/assets/javascripts/discourse/models/user-posts-stream.js.es6
+++ b/app/assets/javascripts/discourse/models/user-posts-stream.js.es6
@@ -1,3 +1,4 @@
+import { on } from "ember-addons/ember-computed-decorators";
 import { ajax } from "discourse/lib/ajax";
 import { url } from "discourse/lib/computed";
 import UserAction from "discourse/models/user-action";
@@ -5,13 +6,14 @@ import UserAction from "discourse/models/user-action";
 export default Discourse.Model.extend({
   loaded: false,
 
-  _initialize: function() {
+  @on("init")
+  _initialize() {
     this.setProperties({
       itemsLoaded: 0,
       canLoadMore: true,
       content: []
     });
-  }.on("init"),
+  },
 
   url: url(
     "user.username_lower",
@@ -40,7 +42,6 @@ export default Discourse.Model.extend({
   },
 
   findItems() {
-    const self = this;
     if (this.loading || !this.canLoadMore) {
       return Ember.RSVP.reject();
     }
@@ -48,21 +49,17 @@ export default Discourse.Model.extend({
     this.set("loading", true);
 
     return ajax(this.url, { cache: false })
-      .then(function(result) {
+      .then(result => {
         if (result) {
-          const posts = result.map(function(post) {
-            return UserAction.create(post);
-          });
-          self.get("content").pushObjects(posts);
-          self.setProperties({
+          const posts = result.map(post => UserAction.create(post));
+          this.content.pushObjects(posts);
+          this.setProperties({
             loaded: true,
-            itemsLoaded: self.get("itemsLoaded") + posts.length,
+            itemsLoaded: this.itemsLoaded + posts.length,
             canLoadMore: posts.length > 0
           });
         }
       })
-      .finally(function() {
-        self.set("loading", false);
-      });
+      .finally(() => this.set("loading", false));
   }
 });

GitHub sha: 63264158