REFACTOR: Pass down `currentUser` to `post-cooked` widget (#7333)
* REFACTOR: Pass down `currentUser` to `post-cooked` widget
This commit is contained in:
parent
fd6b594625
commit
0d2a1fce51
|
@ -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)
|
||||
])
|
||||
])
|
||||
])
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue