From 6f3ad1999e582c6ddee17479cb1bf4ce1e057c15 Mon Sep 17 00:00:00 2001 From: Alexander Skvortsov <38059171+askvortsov1@users.noreply.github.com> Date: Thu, 18 Jun 2020 20:10:25 -0400 Subject: [PATCH] Don't store PostUser instance in CommentPost (#2184) * Don't save component state in CommentPost --- .../js/src/forum/components/CommentPost.js | 15 ++++--------- .../core/js/src/forum/components/PostUser.js | 22 ++----------------- 2 files changed, 6 insertions(+), 31 deletions(-) diff --git a/framework/core/js/src/forum/components/CommentPost.js b/framework/core/js/src/forum/components/CommentPost.js index 0ca868b09..d505f1174 100644 --- a/framework/core/js/src/forum/components/CommentPost.js +++ b/framework/core/js/src/forum/components/CommentPost.js @@ -31,13 +31,7 @@ export default class CommentPost extends Post { */ this.revealContent = false; - // Create an instance of the component that displays the post's author so - // 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() - ); + this.subtree.check(() => this.isEditing()); } content() { @@ -129,13 +123,12 @@ export default class CommentPost extends Post { headerItems() { const items = new ItemList(); const post = this.props.post; - const props = { post }; - items.add('user', this.postUser.render(), 100); - items.add('meta', PostMeta.component(props)); + items.add('user', PostUser.component({ post }), 100); + items.add('meta', PostMeta.component({ post })); 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 diff --git a/framework/core/js/src/forum/components/PostUser.js b/framework/core/js/src/forum/components/PostUser.js index bbceea424..7ecb2558a 100644 --- a/framework/core/js/src/forum/components/PostUser.js +++ b/framework/core/js/src/forum/components/PostUser.js @@ -13,15 +13,6 @@ import listItems from '../../common/helpers/listItems'; * - `post` */ export default class PostUser extends Component { - init() { - /** - * Whether or not the user hover card is visible. - * - * @type {Boolean} - */ - this.cardVisible = false; - } - view() { const post = this.props.post; const user = post.user(); @@ -38,7 +29,7 @@ export default class PostUser extends Component { let card = ''; - if (!post.isHidden() && this.cardVisible) { + if (!post.isHidden()) { card = UserCard.component({ user, className: 'UserCard--popover', @@ -81,10 +72,6 @@ export default class PostUser extends Component { * Show the user card. */ showCard() { - this.cardVisible = true; - - m.redraw(); - setTimeout(() => this.$('.UserCard').addClass('in')); } @@ -92,11 +79,6 @@ export default class PostUser extends Component { * Hide the user card. */ hideCard() { - this.$('.UserCard') - .removeClass('in') - .one('transitionend webkitTransitionEnd oTransitionEnd', () => { - this.cardVisible = false; - m.redraw(); - }); + this.$('.UserCard').removeClass('in'); } }