DEV: attemps to limit Discourse.User.current() usage (#7943)

DEV: attemps to limit Discourse.User.current() usage (#7943)

diff --git a/app/assets/javascripts/admin/controllers/admin-backups-index.js.es6 b/app/assets/javascripts/admin/controllers/admin-backups-index.js.es6
index 07cd082..684f844 100644
--- a/app/assets/javascripts/admin/controllers/admin-backups-index.js.es6
+++ b/app/assets/javascripts/admin/controllers/admin-backups-index.js.es6
@@ -29,7 +29,7 @@ export default Ember.Controller.extend({
           I18n.t("yes_value"),
           confirmed => {
             if (confirmed) {
-              Discourse.User.currentProp("hideReadOnlyAlert", true);
+              this.set("currentUser.hideReadOnlyAlert", true);
               this._toggleReadOnlyMode(true);
             }
           }
diff --git a/app/assets/javascripts/admin/controllers/admin-user-index.js.es6 b/app/assets/javascripts/admin/controllers/admin-user-index.js.es6
index 79eceed..4a24bbd 100644
--- a/app/assets/javascripts/admin/controllers/admin-user-index.js.es6
+++ b/app/assets/javascripts/admin/controllers/admin-user-index.js.es6
@@ -134,7 +134,7 @@ export default Ember.Controller.extend(CanCheckEmails, {
       return this.model.resetBounceScore();
     },
     approve() {
-      return this.model.approve();
+      return this.model.approve(this.currentUser);
     },
     deactivate() {
       return this.model.deactivate();
diff --git a/app/assets/javascripts/admin/models/admin-user.js.es6 b/app/assets/javascripts/admin/models/admin-user.js.es6
index f5ff4c2..bd830be 100644
--- a/app/assets/javascripts/admin/models/admin-user.js.es6
+++ b/app/assets/javascripts/admin/models/admin-user.js.es6
@@ -227,14 +227,14 @@ const AdminUser = Discourse.User.extend({
       .catch(popupAjaxError);
   },
 
-  approve() {
+  approve(approvedBy) {
     return ajax(`/admin/users/${this.id}/approve`, {
       type: "PUT"
     }).then(() => {
       this.setProperties({
         can_approve: false,
         approved: true,
-        approved_by: Discourse.User.current()
+        approved_by: approvedBy
       });
     });
   },
diff --git a/app/assets/javascripts/admin/routes/admin-users-list.js.es6 b/app/assets/javascripts/admin/routes/admin-users-list.js.es6
index f2edad8..d6b7635 100644
--- a/app/assets/javascripts/admin/routes/admin-users-list.js.es6
+++ b/app/assets/javascripts/admin/routes/admin-users-list.js.es6
@@ -11,7 +11,7 @@ export default Discourse.Route.extend({
     },
 
     sendInvites() {
-      this.transitionTo("userInvited", Discourse.User.current());
+      this.transitionTo("userInvited", this.currentUser);
     },
 
     deleteUser(user) {
diff --git a/app/assets/javascripts/discourse/components/composer-editor.js.es6 b/app/assets/javascripts/discourse/components/composer-editor.js.es6
index 56a82f7..4ef3193 100644
--- a/app/assets/javascripts/discourse/components/composer-editor.js.es6
+++ b/app/assets/javascripts/discourse/components/composer-editor.js.es6
@@ -237,7 +237,7 @@ export default Ember.Component.extend({
       reason = I18n.t("composer.error.post_missing");
     } else if (missingReplyCharacters > 0) {
       reason = I18n.t("composer.error.post_length", { min: minimumPostLength });
-      const tl = Discourse.User.currentProp("trust_level");
+      const tl = this.get("currentUser.trust_level");
       if (tl === 0 || tl === 1) {
         reason +=
           "<br/>" +
diff --git a/app/assets/javascripts/discourse/components/topic-status.js.es6 b/app/assets/javascripts/discourse/components/topic-status.js.es6
index a8dbe46..d063847 100644
--- a/app/assets/javascripts/discourse/components/topic-status.js.es6
+++ b/app/assets/javascripts/discourse/components/topic-status.js.es6
@@ -29,7 +29,7 @@ export default Ember.Component.extend(
 
     @computed("disableActions")
     canAct(disableActions) {
-      return Discourse.User.current() && !disableActions;
+      return this.currentUser && !disableActions;
     },
 
     buildBuffer(buffer) {
diff --git a/app/assets/javascripts/discourse/controllers/application.js.es6 b/app/assets/javascripts/discourse/controllers/application.js.es6
index 0d02180..7cd2898 100644
--- a/app/assets/javascripts/discourse/controllers/application.js.es6
+++ b/app/assets/javascripts/discourse/controllers/application.js.es6
@@ -17,7 +17,7 @@ export default Ember.Controller.extend({
 
   @computed
   loginRequired() {
-    return Discourse.SiteSettings.login_required && !Discourse.User.current();
+    return Discourse.SiteSettings.login_required && !this.currentUser;
   },
 
   @computed
diff --git a/app/assets/javascripts/discourse/controllers/composer.js.es6 b/app/assets/javascripts/discourse/controllers/composer.js.es6
index d77a4a4..b96051e 100644
--- a/app/assets/javascripts/discourse/controllers/composer.js.es6
+++ b/app/assets/javascripts/discourse/controllers/composer.js.es6
@@ -292,7 +292,7 @@ export default Ember.Controller.extend({
 
   @computed("model.creatingPrivateMessage", "model.targetUsernames")
   showWarning(creatingPrivateMessage, usernames) {
-    if (!Discourse.User.currentProp("staff")) {
+    if (!this.get("currentUser.staff")) {
       return false;
     }
 
diff --git a/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6 b/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6
index dedcef9..2d8cc9f 100644
--- a/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6
+++ b/app/assets/javascripts/discourse/controllers/discovery/categories.js.es6
@@ -14,10 +14,7 @@ export default DiscoveryController.extend({
   // this makes sure the composer isn't scoping to a specific category
   category: null,
 
-  @computed
-  canEdit() {
-    return Discourse.User.currentProp("staff");
-  },
+  canEdit: Ember.computed.reads("currentUser.staff"),
 
   @computed("model.categories.[].featuredTopics.length")
   latestTopicOnly() {
diff --git a/app/assets/javascripts/discourse/controllers/user-invited-show.js.es6 b/app/assets/javascripts/discourse/controllers/user-invited-show.js.es6
index d7450ae..23bbd45 100644
--- a/app/assets/javascripts/discourse/controllers/user-invited-show.js.es6
+++ b/app/assets/javascripts/discourse/controllers/user-invited-show.js.es6
@@ -42,15 +42,9 @@ export default Ember.Controller.extend({
     );
   },
 
-  @computed
-  canInviteToForum() {
-    return Discourse.User.currentProp("can_invite_to_forum");
-  },
+  canInviteToForum: Ember.computed.reads("currentUser.can_invite_to_forum"),
 
-  @computed
-  canBulkInvite() {
-    return Discourse.User.currentProp("admin");
-  },
+  canBulkInvite: Ember.computed.reads("currentUser.admin"),
 
   showSearch: Ember.computed.gte("totalInvites", 10),
 
diff --git a/app/assets/javascripts/discourse/controllers/user-private-messages.js.es6 b/app/assets/javascripts/discourse/controllers/user-private-messages.js.es6
index 0d08726..c5e1bd9 100644
--- a/app/assets/javascripts/discourse/controllers/user-private-messages.js.es6
+++ b/app/assets/javascripts/discourse/controllers/user-private-messages.js.es6
@@ -16,12 +16,10 @@ export default Ember.Controller.extend({
   pmTaggingEnabled: Ember.computed.alias("site.can_tag_pms"),
   tagId: null,
 
-  @computed("user.viewingSelf")
-  showNewPM(viewingSelf) {
-    return (
-      viewingSelf && Discourse.User.currentProp("can_send_private_messages")
-    );
-  },
+  showNewPM: Ember.computed.and(
+    "user.viewingSelf",
+    "currentUser.can_send_private_messages"
+  ),
 
   @computed("selected.[]", "bulkSelectEnabled")
   hasSelection(selected, bulkSelectEnabled) {
diff --git a/app/assets/javascripts/discourse/initializers/subscribe-user-notifications.js.es6 b/app/assets/javascripts/discourse/initializers/subscribe-user-notifications.js.es6
index 44f4025..b71f37a 100644
--- a/app/assets/javascripts/discourse/initializers/subscribe-user-notifications.js.es6
+++ b/app/assets/javascripts/discourse/initializers/subscribe-user-notifications.js.es6
@@ -131,12 +131,7 @@ export default {
 
         if (isPushNotificationsEnabled(user, site.mobileView)) {
           disableDesktopNotifications();
-          registerPushNotifications(

[... diff too long, it was truncated ...]

GitHub sha: fe7f0982