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/more_direct_channels.jsx | 33 +++++++++++++++++++----------- 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'webapp/components/more_direct_channels.jsx') diff --git a/webapp/components/more_direct_channels.jsx b/webapp/components/more_direct_channels.jsx index 2d4780359..1b287b3b2 100644 --- a/webapp/components/more_direct_channels.jsx +++ b/webapp/components/more_direct_channels.jsx @@ -35,6 +35,8 @@ export default class MoreDirectChannels extends React.Component { this.nextPage = this.nextPage.bind(this); this.search = this.search.bind(this); + this.searchTimeoutId = 0; + this.state = { users: null, loadingDMChannel: -1, @@ -168,19 +170,26 @@ export default class MoreDirectChannels extends React.Component { teamId = TeamStore.getCurrentId(); } - searchUsers( - term, - teamId, - {}, - (users) => { - for (let i = 0; i < users.length; i++) { - if (users[i].id === UserStore.getCurrentId()) { - users.splice(i, 1); - break; + clearTimeout(this.searchTimeoutId); + + this.searchTimeoutId = setTimeout( + () => { + searchUsers( + term, + teamId, + {}, + (users) => { + for (let i = 0; i < users.length; i++) { + if (users[i].id === UserStore.getCurrentId()) { + users.splice(i, 1); + break; + } + } + this.setState({search: true, users}); } - } - this.setState({search: true, users}); - } + ); + }, + Constants.SEARCH_TIMEOUT_MILLISECONDS ); } -- cgit v1.2.3-1-g7c22