diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-12-20 09:08:58 -0500 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2016-12-20 09:08:58 -0500 |
commit | bf3fec604fc4ad0fd53d38490c18d872bccd629d (patch) | |
tree | 345838245dd4781d890009cc043dfa2723251ed4 /webapp/components/suggestion/search_user_provider.jsx | |
parent | d4b890fff10a459a39c2405d2e0f1ecf36b79542 (diff) | |
download | chat-bf3fec604fc4ad0fd53d38490c18d872bccd629d.tar.gz chat-bf3fec604fc4ad0fd53d38490c18d872bccd629d.tar.bz2 chat-bf3fec604fc4ad0fd53d38490c18d872bccd629d.zip |
Remove autocomplete delay (#4819)
Diffstat (limited to 'webapp/components/suggestion/search_user_provider.jsx')
-rw-r--r-- | webapp/components/suggestion/search_user_provider.jsx | 49 |
1 files changed, 16 insertions, 33 deletions
diff --git a/webapp/components/suggestion/search_user_provider.jsx b/webapp/components/suggestion/search_user_provider.jsx index 2aa72aef5..6fce8edcf 100644 --- a/webapp/components/suggestion/search_user_provider.jsx +++ b/webapp/components/suggestion/search_user_provider.jsx @@ -8,7 +8,7 @@ import {autocompleteUsersInTeam} from 'actions/user_actions.jsx'; import AppDispatcher from 'dispatcher/app_dispatcher.jsx'; import Client from 'client/web_client.jsx'; import * as Utils from 'utils/utils.jsx'; -import {Constants, ActionTypes} from 'utils/constants.jsx'; +import {ActionTypes} from 'utils/constants.jsx'; import React from 'react'; @@ -57,43 +57,26 @@ class SearchUserSuggestion extends Suggestion { } export default class SearchUserProvider { - constructor() { - this.timeoutId = ''; - } - - componentWillUnmount() { - clearTimeout(this.timeoutId); - } - handlePretextChanged(suggestionId, pretext) { - clearTimeout(this.timeoutId); - const captured = (/\bfrom:\s*(\S*)$/i).exec(pretext.toLowerCase()); if (captured) { const usernamePrefix = captured[1]; - function autocomplete() { - autocompleteUsersInTeam( - usernamePrefix, - (data) => { - const users = data.in_team; - const mentions = users.map((user) => user.username); - - AppDispatcher.handleServerAction({ - type: ActionTypes.SUGGESTION_RECEIVED_SUGGESTIONS, - id: suggestionId, - matchedPretext: usernamePrefix, - terms: mentions, - items: users, - component: SearchUserSuggestion - }); - } - ); - } - - this.timeoutId = setTimeout( - autocomplete.bind(this), - Constants.AUTOCOMPLETE_TIMEOUT + autocompleteUsersInTeam( + usernamePrefix, + (data) => { + const users = data.in_team; + const mentions = users.map((user) => user.username); + + AppDispatcher.handleServerAction({ + type: ActionTypes.SUGGESTION_RECEIVED_SUGGESTIONS, + id: suggestionId, + matchedPretext: usernamePrefix, + terms: mentions, + items: users, + component: SearchUserSuggestion + }); + } ); } } |