1
0
mirror of https://github.com/flarum/core.git synced 2025-07-26 11:10:41 +02:00

PERF: more efficient retaining of posts

This commit is contained in:
Toby Zerner
2015-07-28 22:58:17 +09:30
parent 459e428f4a
commit e466fa2f7c

View File

@@ -34,14 +34,16 @@ export default class Post extends Component {
} }
view() { view() {
const controls = PostControls.controls(this.props.post, this).toArray();
const attrs = this.attrs(); const attrs = this.attrs();
attrs.className = 'Post ' + (attrs.className || ''); attrs.className = 'Post ' + (attrs.className || '');
return ( return (
<article {...attrs}> <article {...attrs}>
{this.subtree.retain() || ( {this.subtree.retain() || (() => {
const controls = PostControls.controls(this.props.post, this).toArray();
return (
<div> <div>
{controls.length ? Dropdown.component({ {controls.length ? Dropdown.component({
children: controls, children: controls,
@@ -52,7 +54,8 @@ export default class Post extends Component {
{this.content()} {this.content()}
</div> </div>
)} );
})()}
</article> </article>
); );
} }
@@ -63,6 +66,7 @@ export default class Post extends Component {
* @return {Object} * @return {Object}
*/ */
attrs() { attrs() {
return {};
} }
/** /**
@@ -71,5 +75,6 @@ export default class Post extends Component {
* @return {Object} * @return {Object}
*/ */
content() { content() {
return '';
} }
} }