From 6b2c4a346ba9c50d533eadb2c64086d67d32c565 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Mon, 16 Jan 2017 18:32:51 -0500 Subject: Discard outdated results in modal searches (#5082) --- webapp/components/channel_invite_modal.jsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (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 355d23d53..5deec0794 100644 --- a/webapp/components/channel_invite_modal.jsx +++ b/webapp/components/channel_invite_modal.jsx @@ -117,19 +117,25 @@ export default class ChannelInviteModal extends React.Component { clearTimeout(this.searchTimeoutId); - this.searchTimeoutId = setTimeout( + const searchTimeoutId = setTimeout( () => { searchUsers( term, TeamStore.getCurrentId(), {not_in_channel_id: this.props.channel.id}, (users) => { + if (searchTimeoutId !== this.searchTimeoutId) { + return; + } + this.setState({search: true, users}); } ); }, Constants.SEARCH_TIMEOUT_MILLISECONDS ); + + this.searchTimeoutId = searchTimeoutId; } render() { -- cgit v1.2.3-1-g7c22