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/more_channels.jsx | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

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

diff --git a/webapp/components/more_channels.jsx b/webapp/components/more_channels.jsx
index d0b5f5399..10f597ad4 100644
--- a/webapp/components/more_channels.jsx
+++ b/webapp/components/more_channels.jsx
@@ -99,14 +99,15 @@ export default class MoreChannels extends React.Component {
     }
 
     search(term) {
+        clearTimeout(this.searchTimeoutId);
+
         if (term === '') {
             this.onChange(true);
             this.setState({search: false});
+            this.searchTimeoutId = '';
             return;
         }
 
-        clearTimeout(this.searchTimeoutId);
-
         const searchTimeoutId = setTimeout(
             () => {
                 searchMoreChannels(
-- 
cgit v1.2.3-1-g7c22

