From 28679bfba2d4160cd54fe368e5412aa622cd8c6e Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Mon, 25 Jun 2018 13:02:30 +0300 Subject: transform-class-properties --- vnext/src/components/Chat.js | 3 +-- vnext/src/components/Feeds.js | 3 +-- vnext/src/components/LoginButton.js | 15 +++++++-------- vnext/src/components/MessageInput.js | 16 +++++----------- vnext/src/components/Thread.js | 8 +++----- vnext/src/index.js | 5 ++--- 6 files changed, 19 insertions(+), 31 deletions(-) (limited to 'vnext/src') diff --git a/vnext/src/components/Chat.js b/vnext/src/components/Chat.js index 79425c12..c4d9422f 100644 --- a/vnext/src/components/Chat.js +++ b/vnext/src/components/Chat.js @@ -11,13 +11,12 @@ export default class Chat extends React.Component { this.state = { chats: [] }; - this.loadChat = this.loadChat.bind(this); } componentWillMount() { this.loadChat(this.props.match.params.user); } - loadChat(uname) { + loadChat = (uname) => { const { hash } = this.props.visitor; this.setState({ chats: [] diff --git a/vnext/src/components/Feeds.js b/vnext/src/components/Feeds.js index 0f12575f..5e9c14d0 100644 --- a/vnext/src/components/Feeds.js +++ b/vnext/src/components/Feeds.js @@ -61,7 +61,6 @@ class Feed extends React.Component { this.state = { msgs: [] }; - this.loadMessages = this.loadMessages.bind(this); } componentDidMount() { this.loadMessages(this.props.visitor.hash, this.props.location.search); @@ -72,7 +71,7 @@ class Feed extends React.Component { this.loadMessages(nextProps.visitor.hash, nextProps.location.search) } } - loadMessages(hash = '', filter = '') { + loadMessages = (hash = '', filter = '') => { document.body.scrollTop = 0; document.documentElement.scrollTop = 0; this.setState({ msgs: [] }) diff --git a/vnext/src/components/LoginButton.js b/vnext/src/components/LoginButton.js index 22ae2198..fb3c087e 100644 --- a/vnext/src/components/LoginButton.js +++ b/vnext/src/components/LoginButton.js @@ -11,25 +11,24 @@ export default class LoginButton extends React.Component { username: '', password: '' }; - this.toggleModal = this.toggleModal.bind(this); } - toggleModal(event) { + toggleModal = (event) => { if (event) event.preventDefault() this.setState({ isOpen: !this.state.isOpen }); } - usernameChanged(event) { + usernameChanged = (event) => { this.setState({ username: event.target.value }) } - passwordChanged(event) { + passwordChanged = (event) => { this.setState({ password: event.target.value }) } - login(event) { + login = (event) => { event.preventDefault(); let headers = new Headers(); headers.append('Authorization', 'Basic ' + window.btoa(unescape(encodeURIComponent(this.state.username + ":" + this.state.password)))); @@ -67,16 +66,16 @@ export default class LoginButton extends React.Component {

Already registered?

-
+
+ value={this.state.username} onChange={this.usernameChanged} />

+ value={this.state.password} onChange={this.passwordChanged} />
diff --git a/vnext/src/components/MessageInput.js b/vnext/src/components/MessageInput.js index 6e698c32..e30962a8 100644 --- a/vnext/src/components/MessageInput.js +++ b/vnext/src/components/MessageInput.js @@ -9,12 +9,6 @@ import Button from './Button'; export default class MessageInput extends React.Component { constructor(props) { super(props) - this.textChanged = this.textChanged.bind(this); - this.attachmentChanged = this.attachmentChanged.bind(this); - this.openfile = this.openfile.bind(this); - this.handleCtrlEnter = this.handleCtrlEnter.bind(this); - this.onSubmit = this.onSubmit.bind(this); - this.textarea = React.createRef(); this.fileinput = React.createRef(); this.state = { @@ -26,13 +20,13 @@ export default class MessageInput extends React.Component { } } - handleCtrlEnter(event) { + handleCtrlEnter = (event) => { if (event.ctrlKey && (event.charCode == 10 || event.charCode == 13)) { this.onSubmit({}) } } - onSubmit(event) { + onSubmit = (event) => { if (event.preventDefault) event.preventDefault(); const input = this.fileinput.current; this.props.onSend({ @@ -50,7 +44,7 @@ export default class MessageInput extends React.Component { componentDidMount() { this.textarea.current.focus() } - textChanged(event) { + textChanged = (event) => { this.setState({ body: event.target.value }) @@ -59,12 +53,12 @@ export default class MessageInput extends React.Component { const height = el.scrollHeight + offset; el.style.height = `${height + offset}px`; } - attachmentChanged(event) { + attachmentChanged = (event) => { this.setState({ attach: event.target.value }) } - openfile() { + openfile = () => { const input = this.fileinput.current; if (this.state.attach) { this.setState({ diff --git a/vnext/src/components/Thread.js b/vnext/src/components/Thread.js index 5ff91346..17c5b55c 100644 --- a/vnext/src/components/Thread.js +++ b/vnext/src/components/Thread.js @@ -21,8 +21,6 @@ export default class Thread extends React.Component { replies: [], active: 0 }; - this.loaded = this.loaded.bind(this); - this.postComment = this.postComment.bind(this); } componentDidMount() { document.body.scrollTop = 0; @@ -55,7 +53,7 @@ export default class Thread extends React.Component { console.log(ex); }); } - loaded() { + loaded = () => { return (this.state.replies && this.state.replies.length > 0) || ('mid' in this.state.msg && !('replies' in this.state.msg)); } setActive(msg, event) { @@ -63,7 +61,7 @@ export default class Thread extends React.Component { active: msg.rid || 0 }) } - postComment(template) { + postComment = (template) => { const url = `https://api.juick.com/comment?hash=${this.props.visitor.hash}`; let form = new FormData(); form.append('mid', template.mid); @@ -150,7 +148,7 @@ export default class Thread extends React.Component { { this.props.visitor.uid > 0 ? ( - {this.state.active === msg.rid || } + {this.state.active === msg.rid || } {this.state.active === msg.rid && } ) : ( diff --git a/vnext/src/index.js b/vnext/src/index.js index 556745ff..2caaf5bb 100644 --- a/vnext/src/index.js +++ b/vnext/src/index.js @@ -20,7 +20,6 @@ const elClassBackground = 'header--background'; class App extends React.Component { constructor(props) { super(props); - this.auth = this.auth.bind(this); let params = qs.parse(window.location.search) if (params.hash) { window.localStorage.hash = params.hash @@ -125,7 +124,7 @@ class App extends React.Component { {user.uid > 0 ? Post : - + } @@ -216,7 +215,7 @@ class App extends React.Component { ) } - auth(data) { + auth = (data) => { if (data) { window.localStorage.hash = data; fetch(`https://api.juick.com/users?hash=${data}`) -- cgit v1.2.3