From cadc9e11e4c5456bae97d8ba4031ea9e72edf7fb Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Wed, 21 Dec 2016 12:45:21 -0500 Subject: Remove race between multiple autocomplete requests (#4860) --- webapp/components/suggestion/switch_channel_provider.jsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'webapp/components/suggestion/switch_channel_provider.jsx') diff --git a/webapp/components/suggestion/switch_channel_provider.jsx b/webapp/components/suggestion/switch_channel_provider.jsx index bf9e7c646..35ce4d578 100644 --- a/webapp/components/suggestion/switch_channel_provider.jsx +++ b/webapp/components/suggestion/switch_channel_provider.jsx @@ -2,6 +2,7 @@ // See License.txt for license information. import Suggestion from './suggestion.jsx'; +import Provider from './provider.jsx'; import ChannelStore from 'stores/channel_store.jsx'; import UserStore from 'stores/user_store.jsx'; @@ -58,15 +59,21 @@ class SwitchChannelSuggestion extends Suggestion { } } -export default class SwitchChannelProvider { +export default class SwitchChannelProvider extends Provider { handlePretextChanged(suggestionId, channelPrefix) { if (channelPrefix) { + this.startNewRequest(channelPrefix); + const allChannels = ChannelStore.getAll(); const channels = []; autocompleteUsers( channelPrefix, (users) => { + if (this.shouldCancelDispatch(channelPrefix)) { + return; + } + const currentId = UserStore.getCurrentId(); for (const id of Object.keys(allChannels)) { -- cgit v1.2.3-1-g7c22