From 7f48a7fc9d2238134414668e0b520115706b8b2d Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Thu, 15 Dec 2016 11:40:46 -0500 Subject: PLT-4815 Refactor 'More Channels' modal into the new modal pattern (#4742) * Refactor 'More Channels' modal into the new modal pattern * Fix unit test * Readded CSS changes --- webapp/components/channel_invite_modal.jsx | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 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 4b72cfc40..355d23d53 100644 --- a/webapp/components/channel_invite_modal.jsx +++ b/webapp/components/channel_invite_modal.jsx @@ -13,6 +13,7 @@ import {searchUsers} from 'actions/user_actions.jsx'; import * as AsyncClient from 'utils/async_client.jsx'; import * as UserAgent from 'utils/user_agent.jsx'; +import Constants from 'utils/constants.jsx'; import React from 'react'; import {Modal} from 'react-bootstrap'; @@ -32,6 +33,7 @@ export default class ChannelInviteModal extends React.Component { this.search = this.search.bind(this); this.term = ''; + this.searchTimeoutId = 0; const channelStats = ChannelStore.getStats(props.channel.id); const teamStats = TeamStore.getCurrentStats(); @@ -113,13 +115,20 @@ export default class ChannelInviteModal extends React.Component { return; } - searchUsers( - term, - TeamStore.getCurrentId(), - {not_in_channel_id: this.props.channel.id}, - (users) => { - this.setState({search: true, users}); - } + clearTimeout(this.searchTimeoutId); + + this.searchTimeoutId = setTimeout( + () => { + searchUsers( + term, + TeamStore.getCurrentId(), + {not_in_channel_id: this.props.channel.id}, + (users) => { + this.setState({search: true, users}); + } + ); + }, + Constants.SEARCH_TIMEOUT_MILLISECONDS ); } -- cgit v1.2.3-1-g7c22