diff options
author | Joram Wilander <jwawilander@gmail.com> | 2016-12-21 12:45:21 -0500 |
---|---|---|
committer | Harrison Healey <harrisonmhealey@gmail.com> | 2016-12-21 12:45:21 -0500 |
commit | cadc9e11e4c5456bae97d8ba4031ea9e72edf7fb (patch) | |
tree | a1d98954c3fdc2fbd30a04289c0b6c5430f45ad9 /webapp/components/suggestion/channel_mention_provider.jsx | |
parent | 26e43c671c4252dccbf3b0e9257407d41e4297ae (diff) | |
download | chat-cadc9e11e4c5456bae97d8ba4031ea9e72edf7fb.tar.gz chat-cadc9e11e4c5456bae97d8ba4031ea9e72edf7fb.tar.bz2 chat-cadc9e11e4c5456bae97d8ba4031ea9e72edf7fb.zip |
Remove race between multiple autocomplete requests (#4860)
Diffstat (limited to 'webapp/components/suggestion/channel_mention_provider.jsx')
-rw-r--r-- | webapp/components/suggestion/channel_mention_provider.jsx | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/webapp/components/suggestion/channel_mention_provider.jsx b/webapp/components/suggestion/channel_mention_provider.jsx index 7c781a2f7..63e6944ac 100644 --- a/webapp/components/suggestion/channel_mention_provider.jsx +++ b/webapp/components/suggestion/channel_mention_provider.jsx @@ -2,6 +2,7 @@ // See License.txt for license information. import Suggestion from './suggestion.jsx'; +import Provider from './provider.jsx'; import {autocompleteChannels} from 'actions/channel_actions.jsx'; @@ -49,15 +50,21 @@ class ChannelMentionSuggestion extends Suggestion { } } -export default class ChannelMentionProvider { +export default class ChannelMentionProvider extends Provider { handlePretextChanged(suggestionId, pretext) { const captured = (/(^|\s)(~([^~]*))$/i).exec(pretext.toLowerCase()); if (captured) { const prefix = captured[3]; + this.startNewRequest(prefix); + autocompleteChannels( prefix, (data) => { + if (this.shouldCancelDispatch(prefix)) { + return; + } + const channels = data; // Wrap channels in an outer object to avoid overwriting the 'type' property. |