From caa7f813eb054b59a5510c3de15878789d0755c5 Mon Sep 17 00:00:00 2001
From: David Baker <dave@matrix.org>
Date: Sun, 19 Jul 2015 17:29:41 +0100
Subject: [PATCH] Bugfix sending of typing events

---
 src/controllers/molecules/MessageComposer.js | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/controllers/molecules/MessageComposer.js b/src/controllers/molecules/MessageComposer.js
index f2af22e5..066cdd64 100644
--- a/src/controllers/molecules/MessageComposer.js
+++ b/src/controllers/molecules/MessageComposer.js
@@ -351,15 +351,22 @@ module.exports = {
     },
 
     stopUserTypingTimer: function() {
-        clearTimeout(this.userTypingTimer);
+        if (this.userTypingTimer) {
+            clearTimeout(this.userTypingTimer);
+            this.userTypingTimer = null;
+        }
     },
 
     startServerTypingTimer: function() {
-        var self = this;
-        this.serverTypingTimer = setTimeout(function() {
-            self.sendTyping(self.isTyping);
-            self.startServerTypingTimer();
-        }, TYPING_SERVER_TIMEOUT / 2);
+        if (!this.serverTypingTimer) {
+            var self = this;
+            this.serverTypingTimer = setTimeout(function() {
+                if (self.isTyping) {
+                    self.sendTyping(self.isTyping);
+                    self.startServerTypingTimer();
+                }
+            }, TYPING_SERVER_TIMEOUT / 2);
+        }
     },
 
     stopServerTypingTimer: function() {