From e466fa2f7cb945ed766cd51ea807a1abf4bb9d9a Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Tue, 28 Jul 2015 22:58:17 +0930 Subject: [PATCH] PERF: more efficient retaining of posts --- .../core/js/forum/src/components/Post.js | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/framework/core/js/forum/src/components/Post.js b/framework/core/js/forum/src/components/Post.js index c5ff5a412..d6b72089a 100644 --- a/framework/core/js/forum/src/components/Post.js +++ b/framework/core/js/forum/src/components/Post.js @@ -34,25 +34,28 @@ export default class Post extends Component { } view() { - const controls = PostControls.controls(this.props.post, this).toArray(); const attrs = this.attrs(); attrs.className = 'Post ' + (attrs.className || ''); return (
- {this.subtree.retain() || ( -
- {controls.length ? Dropdown.component({ - children: controls, - className: 'Post-controls', - buttonClassName: 'Button Button--icon Button--flat', - menuClassName: 'Dropdown-menu--right' - }) : ''} + {this.subtree.retain() || (() => { + const controls = PostControls.controls(this.props.post, this).toArray(); - {this.content()} -
- )} + return ( +
+ {controls.length ? Dropdown.component({ + children: controls, + className: 'Post-controls', + buttonClassName: 'Button Button--icon Button--flat', + menuClassName: 'Dropdown-menu--right' + }) : ''} + + {this.content()} +
+ ); + })()}
); } @@ -63,6 +66,7 @@ export default class Post extends Component { * @return {Object} */ attrs() { + return {}; } /** @@ -71,5 +75,6 @@ export default class Post extends Component { * @return {Object} */ content() { + return ''; } }