summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorFlorian Orben <florian.orben@gmail.com>2015-10-26 17:44:29 +0100
committerFlorian Orben <florian.orben@gmail.com>2015-10-26 17:46:56 +0100
commit9a4d648c9b9a6c78cd2a171b665bc5aa9ade3634 (patch)
treea032c106ac42da872c3744674a9d0129b08f9e92 /web
parentb7aa4220d575d446830a0b0c9a3f753214272422 (diff)
downloadchat-9a4d648c9b9a6c78cd2a171b665bc5aa9ade3634.tar.gz
chat-9a4d648c9b9a6c78cd2a171b665bc5aa9ade3634.tar.bz2
chat-9a4d648c9b9a6c78cd2a171b665bc5aa9ade3634.zip
rename getTypingText to updateTypingText and set component's state in it
Diffstat (limited to 'web')
-rw-r--r--web/react/components/msg_typing.jsx26
1 files changed, 16 insertions, 10 deletions
diff --git a/web/react/components/msg_typing.jsx b/web/react/components/msg_typing.jsx
index 42ae4bcc4..ccf8a2445 100644
--- a/web/react/components/msg_typing.jsx
+++ b/web/react/components/msg_typing.jsx
@@ -12,7 +12,7 @@ export default class MsgTyping extends React.Component {
super(props);
this.onChange = this.onChange.bind(this);
- this.getTypingText = this.getTypingText.bind(this);
+ this.updateTypingText = this.updateTypingText.bind(this);
this.componentWillReceiveProps = this.componentWillReceiveProps.bind(this);
this.typingUsers = {};
@@ -27,7 +27,7 @@ export default class MsgTyping extends React.Component {
componentWillReceiveProps(newProps) {
if (this.props.channelId !== newProps.channelId) {
- this.setState({text: this.getTypingText()});
+ this.updateTypingText();
}
}
@@ -50,31 +50,37 @@ export default class MsgTyping extends React.Component {
this.typingUsers[username] = setTimeout(function myTimer(user) {
delete this.typingUsers[user];
- this.setState({text: this.getTypingText()});
+ this.updateTypingText();
}.bind(this, username), Constants.UPDATE_TYPING_MS);
- this.setState({text: this.getTypingText()});
+ this.updateTypingText();
} else if (msg.action === SocketEvents.POSTED && msg.channel_id === this.props.channelId) {
if (UserStore.hasProfile(msg.user_id)) {
username = UserStore.getProfile(msg.user_id).username;
}
clearTimeout(this.typingUsers[username]);
delete this.typingUsers[username];
- this.setState({text: this.getTypingText()});
+ this.updateTypingText();
}
}
- getTypingText() {
- let users = Object.keys(this.typingUsers);
+ updateTypingText() {
+ const users = Object.keys(this.typingUsers);
+ let text = '';
switch (users.length) {
case 0:
- return '';
+ text = '';
+ break;
case 1:
- return users[0] + ' is typing...';
+ text = users[0] + ' is typing...';
+ break;
default:
const last = users.pop();
- return users.join(', ') + ' and ' + last + ' are typing...';
+ text = users.join(', ') + ' and ' + last + ' are typing...';
+ break;
}
+
+ this.setState({text});
}
render() {