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/features/ui/components/media_modal.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/features/ui/components/media_modal.js')
-rw-r--r-- | app/javascript/mastodon/features/ui/components/media_modal.js | 34 |
1 files changed, 14 insertions, 20 deletions
diff --git a/app/javascript/mastodon/features/ui/components/media_modal.js b/app/javascript/mastodon/features/ui/components/media_modal.js index a8fb3858a..c82ec49e8 100644 --- a/app/javascript/mastodon/features/ui/components/media_modal.js +++ b/app/javascript/mastodon/features/ui/components/media_modal.js @@ -14,25 +14,26 @@ const messages = defineMessages({ class MediaModal extends ImmutablePureComponent { - constructor (props, context) { - super(props, context); - this.state = { - index: null - }; - this.handleNextClick = this.handleNextClick.bind(this); - this.handlePrevClick = this.handlePrevClick.bind(this); - this.handleKeyUp = this.handleKeyUp.bind(this); - } - - handleNextClick () { + static propTypes = { + media: ImmutablePropTypes.list.isRequired, + index: PropTypes.number.isRequired, + onClose: PropTypes.func.isRequired, + intl: PropTypes.object.isRequired + }; + + state = { + index: null + }; + + handleNextClick = () => { this.setState({ index: (this.getIndex() + 1) % this.props.media.size}); } - handlePrevClick () { + handlePrevClick = () => { this.setState({ index: (this.getIndex() - 1) % this.props.media.size}); } - handleKeyUp (e) { + handleKeyUp = (e) => { switch(e.key) { case 'ArrowLeft': this.handlePrevClick(); @@ -93,11 +94,4 @@ class MediaModal extends ImmutablePureComponent { } -MediaModal.propTypes = { - media: ImmutablePropTypes.list.isRequired, - index: PropTypes.number.isRequired, - onClose: PropTypes.func.isRequired, - intl: PropTypes.object.isRequired -}; - export default injectIntl(MediaModal); |