A platform for community discussion. Free, open, simple.
REFACTOR: Pass down `currentUser` to `post-cooked` widget (#7333)
Tarek Khalil0d2a1fce5160
diff --git a/app/assets/javascripts/discourse/widgets/embedded-post.js.es6 b/app/assets/javascripts/discourse/widgets/embedded-post.js.es6index 4702424f2c1..503a4f4e089 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.es6index 14e2069be1f..94627ec704e 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.es6index 14e1a467f69..ae6a3512536 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) {