diff options
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 + }); + } ); } } |