REFACTOR: Pass down `currentUser` to `post-cooked` widget (#7333)

REFACTOR: Pass down currentUser to post-cooked widget (#7333)

  • REFACTOR: Pass down currentUser to post-cooked widget
diff --git a/app/assets/javascripts/discourse/widgets/embedded-post.js.es6 b/app/assets/javascripts/discourse/widgets/embedded-post.js.es6
index 4702424..503a4f4 100644
--- a/app/assets/javascripts/discourse/widgets/embedded-post.js.es6
+++ b/app/assets/javascripts/discourse/widgets/embedded-post.js.es6
@@ -41,7 +41,7 @@ export default createWidget("embedded-post", {
                 shareUrl: attrs.shareUrl
               })
             ]),
-            new PostCooked(attrs, new DecoratorHelper(this))
+            new PostCooked(attrs, new DecoratorHelper(this), this.currentUser)
           ])
         ])
       ])
diff --git a/app/assets/javascripts/discourse/widgets/post-cooked.js.es6 b/app/assets/javascripts/discourse/widgets/post-cooked.js.es6
index 14e2069..94627ec 100644
--- a/app/assets/javascripts/discourse/widgets/post-cooked.js.es6
+++ b/app/assets/javascripts/discourse/widgets/post-cooked.js.es6
@@ -12,18 +12,11 @@ export function addDecorator(cb) {
 }
 
 export default class PostCooked {
-  constructor(attrs, decoratorHelper) {
+  constructor(attrs, decoratorHelper, currentUser) {
     this.attrs = attrs;
     this.expanding = false;
     this._highlighted = false;
-
-    if (decoratorHelper) {
-      this.decoratorHelper = decoratorHelper;
-      if (decoratorHelper.widget && decoratorHelper.widget.currentUser) {
-        this.currentUser = decoratorHelper.widget.currentUser;
-      }
-    }
-
+    this.currentUser = currentUser;
     this.ignoredUsers = this.currentUser
       ? this.currentUser.ignored_users
       : null;
diff --git a/app/assets/javascripts/discourse/widgets/post.js.es6 b/app/assets/javascripts/discourse/widgets/post.js.es6
index 14e1a46..ae6a351 100644
--- a/app/assets/javascripts/discourse/widgets/post.js.es6
+++ b/app/assets/javascripts/discourse/widgets/post.js.es6
@@ -355,7 +355,9 @@ createWidget("post-contents", {
   },
 
   html(attrs, state) {
-    let result = [new PostCooked(attrs, new DecoratorHelper(this))];
+    let result = [
+      new PostCooked(attrs, new DecoratorHelper(this), this.currentUser)
+    ];
     result = result.concat(applyDecorators(this, "after-cooked", attrs, state));
 
     if (attrs.cooked_hidden) {

GitHub sha: 0d2a1fce