mirror of
https://github.com/flarum/framework.git
synced 2025-01-19 16:02:44 +08:00
PERF: more efficient retaining of posts
This commit is contained in:
parent
459e428f4a
commit
e466fa2f7c
|
@ -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 (
|
||||
<article {...attrs}>
|
||||
{this.subtree.retain() || (
|
||||
<div>
|
||||
{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()}
|
||||
</div>
|
||||
)}
|
||||
return (
|
||||
<div>
|
||||
{controls.length ? Dropdown.component({
|
||||
children: controls,
|
||||
className: 'Post-controls',
|
||||
buttonClassName: 'Button Button--icon Button--flat',
|
||||
menuClassName: 'Dropdown-menu--right'
|
||||
}) : ''}
|
||||
|
||||
{this.content()}
|
||||
</div>
|
||||
);
|
||||
})()}
|
||||
</article>
|
||||
);
|
||||
}
|
||||
|
@ -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 '';
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user