diff options
author | Yamagishi Kazutoshi <ykzts@desire.sh> | 2017-05-12 21:44:10 +0900 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-05-12 14:44:10 +0200 |
commit | 2991a7cfe685ca9b42230b7030b9e7d0ece94c88 (patch) | |
tree | 72da0f02bc6279aeab1e641fb7d51527efcb9066 /app/javascript/mastodon/components/status_list.js | |
parent | 44a3584e2d54488393e6f50e482ed61d2765e312 (diff) |
Use ES Class Fields & Static Properties (#3008)
Use ES Class Fields & Static Properties (currently stage 2) for improve class outlook. Added babel-plugin-transform-class-properties as a Babel plugin.
Diffstat (limited to 'app/javascript/mastodon/components/status_list.js')
-rw-r--r-- | app/javascript/mastodon/components/status_list.js | 49 |
1 files changed, 21 insertions, 28 deletions
diff --git a/app/javascript/mastodon/components/status_list.js b/app/javascript/mastodon/components/status_list.js index 9abf1fbfe..0413e9d5f 100644 --- a/app/javascript/mastodon/components/status_list.js +++ b/app/javascript/mastodon/components/status_list.js @@ -9,14 +9,25 @@ import ImmutablePureComponent from 'react-immutable-pure-component'; class StatusList extends ImmutablePureComponent { - constructor (props, context) { - super(props, context); - this.handleScroll = this.handleScroll.bind(this); - this.setRef = this.setRef.bind(this); - this.handleLoadMore = this.handleLoadMore.bind(this); - } - - handleScroll (e) { + static propTypes = { + scrollKey: PropTypes.string.isRequired, + statusIds: ImmutablePropTypes.list.isRequired, + onScrollToBottom: PropTypes.func, + onScrollToTop: PropTypes.func, + onScroll: PropTypes.func, + shouldUpdateScroll: PropTypes.func, + isLoading: PropTypes.bool, + isUnread: PropTypes.bool, + hasMore: PropTypes.bool, + prepend: PropTypes.node, + emptyMessage: PropTypes.node + }; + + static defaultProps = { + trackScroll: true + }; + + handleScroll = (e) => { const { scrollTop, scrollHeight, clientHeight } = e.target; const offset = scrollHeight - scrollTop - clientHeight; this._oldScrollPosition = scrollHeight - scrollTop; @@ -52,11 +63,11 @@ class StatusList extends ImmutablePureComponent { this.node.removeEventListener('scroll', this.handleScroll); } - setRef (c) { + setRef = (c) => { this.node = c; } - handleLoadMore (e) { + handleLoadMore = (e) => { e.preventDefault(); this.props.onScrollToBottom(); } @@ -109,22 +120,4 @@ class StatusList extends ImmutablePureComponent { } -StatusList.propTypes = { - scrollKey: PropTypes.string.isRequired, - statusIds: ImmutablePropTypes.list.isRequired, - onScrollToBottom: PropTypes.func, - onScrollToTop: PropTypes.func, - onScroll: PropTypes.func, - shouldUpdateScroll: PropTypes.func, - isLoading: PropTypes.bool, - isUnread: PropTypes.bool, - hasMore: PropTypes.bool, - prepend: PropTypes.node, - emptyMessage: PropTypes.node -}; - -StatusList.defaultProps = { - trackScroll: true -}; - export default StatusList; |