aboutsummaryrefslogtreecommitdiff
path: root/vnext/src
diff options
context:
space:
mode:
Diffstat (limited to 'vnext/src')
-rw-r--r--vnext/src/components/Chat.js3
-rw-r--r--vnext/src/components/Feeds.js3
-rw-r--r--vnext/src/components/LoginButton.js15
-rw-r--r--vnext/src/components/MessageInput.js16
-rw-r--r--vnext/src/components/Thread.js8
-rw-r--r--vnext/src/index.js5
6 files changed, 19 insertions, 31 deletions
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 {
</a>
</div>
<p>Already registered?</p>
- <form onSubmit={this.login.bind(this)}>
+ <form onSubmit={this.login}>
<input className="signinput"
type="text"
name="username"
placeholder="Username..."
- value={this.state.username} onChange={this.usernameChanged.bind(this)} /><br />
+ value={this.state.username} onChange={this.usernameChanged} /><br />
<input className="signinput"
type="password" name="password"
placeholder="Password..."
- value={this.state.password} onChange={this.passwordChanged.bind(this)} /><br />
+ value={this.state.password} onChange={this.passwordChanged} /><br />
<input className="signsubmit" type="submit" value="OK" />
</form>
</div>
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 ? (
<React.Fragment>
- {this.state.active === msg.rid || <Button onClick={this.setActive.bind(this, msg)}><Icon name="ei-envelope" size="s" />Reply</Button>}
+ {this.state.active === msg.rid || <Button onClick={() => this.setActive(msg)}><Icon name="ei-envelope" size="s" />Reply</Button>}
{this.state.active === msg.rid && <MessageInput data={msg} onSend={this.postComment} />}
</React.Fragment>
) : (
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 ?
<Link to={{ pathname: '/post' }}><Icon name="ei-pencil" size="s" />Post</Link>
:
- <LoginButton title="Login" onAuth={this.auth.bind(this)} />
+ <LoginButton title="Login" onAuth={this.auth} />
}
</li>
</ul>
@@ -216,7 +215,7 @@ class App extends React.Component {
</Router>
)
}
- auth(data) {
+ auth = (data) => {
if (data) {
window.localStorage.hash = data;
fetch(`https://api.juick.com/users?hash=${data}`)