mirror of
https://github.com/flarum/core.git
synced 2025-07-12 12:26:23 +02:00
Don't store PostUser instance in CommentPost (#2184)
* Don't save component state in CommentPost
This commit is contained in:
committed by
GitHub
parent
ed566cd18f
commit
62fe9db732
@ -31,13 +31,7 @@ export default class CommentPost extends Post {
|
|||||||
*/
|
*/
|
||||||
this.revealContent = false;
|
this.revealContent = false;
|
||||||
|
|
||||||
// Create an instance of the component that displays the post's author so
|
this.subtree.check(() => this.isEditing());
|
||||||
// that we can force the post to rerender when the user card is shown.
|
|
||||||
this.postUser = new PostUser({ post: this.props.post });
|
|
||||||
this.subtree.check(
|
|
||||||
() => this.postUser.cardVisible,
|
|
||||||
() => this.isEditing()
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
content() {
|
content() {
|
||||||
@ -129,13 +123,12 @@ export default class CommentPost extends Post {
|
|||||||
headerItems() {
|
headerItems() {
|
||||||
const items = new ItemList();
|
const items = new ItemList();
|
||||||
const post = this.props.post;
|
const post = this.props.post;
|
||||||
const props = { post };
|
|
||||||
|
|
||||||
items.add('user', this.postUser.render(), 100);
|
items.add('user', PostUser.component({ post }), 100);
|
||||||
items.add('meta', PostMeta.component(props));
|
items.add('meta', PostMeta.component({ post }));
|
||||||
|
|
||||||
if (post.isEdited() && !post.isHidden()) {
|
if (post.isEdited() && !post.isHidden()) {
|
||||||
items.add('edited', PostEdited.component(props));
|
items.add('edited', PostEdited.component({ post }));
|
||||||
}
|
}
|
||||||
|
|
||||||
// If the post is hidden, add a button that allows toggling the visibility
|
// If the post is hidden, add a button that allows toggling the visibility
|
||||||
|
@ -13,15 +13,6 @@ import listItems from '../../common/helpers/listItems';
|
|||||||
* - `post`
|
* - `post`
|
||||||
*/
|
*/
|
||||||
export default class PostUser extends Component {
|
export default class PostUser extends Component {
|
||||||
init() {
|
|
||||||
/**
|
|
||||||
* Whether or not the user hover card is visible.
|
|
||||||
*
|
|
||||||
* @type {Boolean}
|
|
||||||
*/
|
|
||||||
this.cardVisible = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
view() {
|
view() {
|
||||||
const post = this.props.post;
|
const post = this.props.post;
|
||||||
const user = post.user();
|
const user = post.user();
|
||||||
@ -38,7 +29,7 @@ export default class PostUser extends Component {
|
|||||||
|
|
||||||
let card = '';
|
let card = '';
|
||||||
|
|
||||||
if (!post.isHidden() && this.cardVisible) {
|
if (!post.isHidden()) {
|
||||||
card = UserCard.component({
|
card = UserCard.component({
|
||||||
user,
|
user,
|
||||||
className: 'UserCard--popover',
|
className: 'UserCard--popover',
|
||||||
@ -81,10 +72,6 @@ export default class PostUser extends Component {
|
|||||||
* Show the user card.
|
* Show the user card.
|
||||||
*/
|
*/
|
||||||
showCard() {
|
showCard() {
|
||||||
this.cardVisible = true;
|
|
||||||
|
|
||||||
m.redraw();
|
|
||||||
|
|
||||||
setTimeout(() => this.$('.UserCard').addClass('in'));
|
setTimeout(() => this.$('.UserCard').addClass('in'));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -92,11 +79,6 @@ export default class PostUser extends Component {
|
|||||||
* Hide the user card.
|
* Hide the user card.
|
||||||
*/
|
*/
|
||||||
hideCard() {
|
hideCard() {
|
||||||
this.$('.UserCard')
|
this.$('.UserCard').removeClass('in');
|
||||||
.removeClass('in')
|
|
||||||
.one('transitionend webkitTransitionEnd oTransitionEnd', () => {
|
|
||||||
this.cardVisible = false;
|
|
||||||
m.redraw();
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user