From cbead2d973fb70bf4dc644dd6a8b8c34b49ff6aa Mon Sep 17 00:00:00 2001
From: Joram Wilander <jwawilander@gmail.com>
Date: Thu, 9 Mar 2017 04:15:38 -0500
Subject: Remove race between clearing lists and search requests (#5686)

---
 webapp/components/channel_invite_modal.jsx | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

(limited to 'webapp/components/channel_invite_modal.jsx')

diff --git a/webapp/components/channel_invite_modal.jsx b/webapp/components/channel_invite_modal.jsx
index 5deec0794..2f1a10a75 100644
--- a/webapp/components/channel_invite_modal.jsx
+++ b/webapp/components/channel_invite_modal.jsx
@@ -107,16 +107,17 @@ export default class ChannelInviteModal extends React.Component {
     }
 
     search(term) {
+        clearTimeout(this.searchTimeoutId);
+
         this.term = term;
 
         if (term === '') {
             this.onChange(true);
             this.setState({search: false});
+            this.searchTimeoutId = '';
             return;
         }
 
-        clearTimeout(this.searchTimeoutId);
-
         const searchTimeoutId = setTimeout(
             () => {
                 searchUsers(
-- 
cgit v1.2.3-1-g7c22

