diff --git a/js/src/forum/components/Post.js b/js/src/forum/components/Post.js index 78bd69dd6..35004352f 100644 --- a/js/src/forum/components/Post.js +++ b/js/src/forum/components/Post.js @@ -10,14 +10,16 @@ import ItemList from '../../common/utils/ItemList'; * includes a controls dropdown; subclasses must implement `content` and `attrs` * methods. * - * ### Props + * ### Attrs * * - `post` * * @abstract */ export default class Post extends Component { - init() { + oninit(vnode) { + super.oninit(vnode); + this.loading = false; /** @@ -27,9 +29,9 @@ export default class Post extends Component { * @type {SubtreeRetainer} */ this.subtree = new SubtreeRetainer( - () => this.props.post.freshness, + () => this.attrs.post.freshness, () => { - const user = this.props.post.user(); + const user = this.attrs.post.user(); return user && user.freshness; }, () => this.controlsOpen @@ -37,51 +39,52 @@ export default class Post extends Component { } view() { - const attrs = this.attrs(); + const attrs = this.elementAttrs(); attrs.className = this.classes(attrs.className).join(' '); + const controls = PostControls.controls(this.attrs.post, this).toArray(); + return (
- {this.subtree.retain() || - (() => { - const controls = PostControls.controls(this.props.post, this).toArray(); - - return ( -
- {this.content()} - -
-
    {listItems(this.footerItems().toArray())}
-
-
- ); - })()} +
+ {this.content()} + + +
); } - config(isInitialized) { + onbeforeupdate(vnode) { + super.onbeforeupdate(vnode); + + return this.subtree.needsRebuild(); + } + + onupdate(vnode) { const $actions = this.$('.Post-actions'); const $controls = this.$('.Post-controls'); @@ -93,7 +96,7 @@ export default class Post extends Component { * * @return {Object} */ - attrs() { + elementAttrs() { return {}; } @@ -115,8 +118,8 @@ export default class Post extends Component { classes(existing) { let classes = (existing || '').split(' ').concat(['Post']); - const user = this.props.post.user(); - const discussion = this.props.post.discussion(); + const user = this.attrs.post.user(); + const discussion = this.attrs.post.discussion(); if (this.loading) { classes.push('Post--loading');