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

