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

* REFACTOR: Pass down `currentUser` to `post-cooked` widget
This commit is contained in:
Tarek Khalil 2019-04-08 14:50:53 +01:00 committed by GitHub
parent fd6b594625
commit 0d2a1fce51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 11 deletions

View File

@ -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)
])
])
])

View File

@ -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;

View File

@ -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) {