From e20f78ad0d20ca7de6acc1150a0d544aebebe9d0 Mon Sep 17 00:00:00 2001
From: JoramWilander <jwawilander@gmail.com>
Date: Wed, 27 Jan 2016 11:27:16 -0500
Subject: Clear user typing text on channel switch

---
 web/react/components/msg_typing.jsx | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

(limited to 'web/react/components/msg_typing.jsx')

diff --git a/web/react/components/msg_typing.jsx b/web/react/components/msg_typing.jsx
index 78b67a216..35a832875 100644
--- a/web/react/components/msg_typing.jsx
+++ b/web/react/components/msg_typing.jsx
@@ -25,9 +25,17 @@ export default class MsgTyping extends React.Component {
         SocketStore.addChangeListener(this.onChange);
     }
 
-    componentWillReceiveProps(newProps) {
-        if (this.props.channelId !== newProps.channelId) {
-            this.updateTypingText();
+    componentWillReceiveProps(nextProps) {
+        if (this.props.channelId !== nextProps.channelId) {
+            for (const u in this.typingUsers) {
+                if (!this.typingUsers.hasOwnProperty(u)) {
+                    continue;
+                }
+
+                clearTimeout(this.typingUsers[u]);
+            }
+            this.typingUsers = {};
+            this.setState({text: ''});
         }
     }
 
-- 
cgit v1.2.3-1-g7c22


From 3f91bc2df2c6f9d8437f258233609e9801b7f8f6 Mon Sep 17 00:00:00 2001
From: Elias Nahum <nahumhbl@gmail.com>
Date: Mon, 1 Feb 2016 17:23:45 -0300
Subject: PLT-7: Refactoring frontend (chunk 9) - sidebar right & rhs

---
 web/react/components/msg_typing.jsx | 42 +++++++++++++++++++++++++++++++------
 1 file changed, 36 insertions(+), 6 deletions(-)

(limited to 'web/react/components/msg_typing.jsx')

diff --git a/web/react/components/msg_typing.jsx b/web/react/components/msg_typing.jsx
index 35a832875..b95b06260 100644
--- a/web/react/components/msg_typing.jsx
+++ b/web/react/components/msg_typing.jsx
@@ -5,9 +5,19 @@ import SocketStore from '../stores/socket_store.jsx';
 import UserStore from '../stores/user_store.jsx';
 
 import Constants from '../utils/constants.jsx';
+
+import {intlShape, injectIntl, defineMessages, FormattedMessage} from 'mm-intl';
+
 const SocketEvents = Constants.SocketEvents;
 
-export default class MsgTyping extends React.Component {
+const holders = defineMessages({
+    someone: {
+        id: 'msg_typing.someone',
+        defaultMessage: 'Someone'
+    }
+});
+
+class MsgTyping extends React.Component {
     constructor(props) {
         super(props);
 
@@ -44,10 +54,10 @@ export default class MsgTyping extends React.Component {
     }
 
     onChange(msg) {
-        let username = 'Someone';
+        let username = this.props.intl.formatMessage(holders.someone);
         if (msg.action === SocketEvents.TYPING &&
-                this.props.channelId === msg.channel_id &&
-                this.props.parentId === msg.props.parent_id) {
+            this.props.channelId === msg.channel_id &&
+            this.props.parentId === msg.props.parent_id) {
             if (UserStore.hasProfile(msg.user_id)) {
                 username = UserStore.getProfile(msg.user_id).username;
             }
@@ -80,11 +90,28 @@ export default class MsgTyping extends React.Component {
             text = '';
             break;
         case 1:
-            text = users[0] + ' is typing...';
+            text = (
+                <FormattedMessage
+                    id='msg_typing.isTyping'
+                    defaultMessage='{user} is typing...'
+                    values={{
+                        user: users[0]
+                    }}
+                />
+            );
             break;
         default: {
             const last = users.pop();
-            text = users.join(', ') + ' and ' + last + ' are typing...';
+            text = (
+                <FormattedMessage
+                    id='msg_typing.areTyping'
+                    defaultMessage='{users} and {last} are typing...'
+                    vaues={{
+                        users: users.join(', '),
+                        last: last
+                    }}
+                />
+            );
             break;
         }
         }
@@ -100,6 +127,9 @@ export default class MsgTyping extends React.Component {
 }
 
 MsgTyping.propTypes = {
+    intl: intlShape.isRequired,
     channelId: React.PropTypes.string,
     parentId: React.PropTypes.string
 };
+
+export default injectIntl(MsgTyping);
\ No newline at end of file
-- 
cgit v1.2.3-1-g7c22

