summaryrefslogtreecommitdiffstats
path: root/webapp/components/suggestion
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/components/suggestion')
-rw-r--r--webapp/components/suggestion/channel_mention_provider.jsx12
-rw-r--r--webapp/components/suggestion/switch_channel_provider.jsx4
2 files changed, 12 insertions, 4 deletions
diff --git a/webapp/components/suggestion/channel_mention_provider.jsx b/webapp/components/suggestion/channel_mention_provider.jsx
index baca006cb..1d85d8082 100644
--- a/webapp/components/suggestion/channel_mention_provider.jsx
+++ b/webapp/components/suggestion/channel_mention_provider.jsx
@@ -54,6 +54,7 @@ export default class ChannelMentionProvider extends Provider {
constructor() {
super();
+ this.lastTermWithNoResults = '';
this.lastCompletedWord = '';
}
@@ -65,6 +66,11 @@ export default class ChannelMentionProvider extends Provider {
return false;
}
+ if (this.lastTermWithNoResults && pretext.startsWith(this.lastTermWithNoResults)) {
+ // Just give up since we know it won't return any results
+ return false;
+ }
+
if (this.lastCompletedWord && captured[0].startsWith(this.lastCompletedWord)) {
// It appears we're still matching a channel handle that we already completed
return false;
@@ -79,12 +85,14 @@ export default class ChannelMentionProvider extends Provider {
autocompleteChannels(
prefix,
- (data) => {
+ (channels) => {
if (this.shouldCancelDispatch(prefix)) {
return;
}
- const channels = data;
+ if (channels.length === 0) {
+ this.lastTermWithNoResults = pretext;
+ }
// Wrap channels in an outer object to avoid overwriting the 'type' property.
const wrappedChannels = [];
diff --git a/webapp/components/suggestion/switch_channel_provider.jsx b/webapp/components/suggestion/switch_channel_provider.jsx
index 98fe21b1a..d4828ead3 100644
--- a/webapp/components/suggestion/switch_channel_provider.jsx
+++ b/webapp/components/suggestion/switch_channel_provider.jsx
@@ -109,7 +109,7 @@ export default class SwitchChannelProvider extends Provider {
// Dispatch suggestions for local data
const channels = getChannelsInCurrentTeam(getState()).concat(getGroupChannels(getState()));
- const users = Object.assign([], searchProfiles(getState(), channelPrefix, true), true);
+ const users = Object.assign([], searchProfiles(getState(), channelPrefix, true));
this.formatChannelsAndDispatch(channelPrefix, suggestionId, channels, users, true);
// Fetch data from the server and dispatch
@@ -141,7 +141,7 @@ export default class SwitchChannelProvider extends Provider {
return;
}
- const users = Object.assign([], searchProfiles(getState(), channelPrefix, true), usersFromServer);
+ const users = Object.assign([], searchProfiles(getState(), channelPrefix, true), usersFromServer.users);
const channels = getChannelsInCurrentTeam(getState()).concat(getGroupChannels(getState())).concat(channelsFromServer);
this.formatChannelsAndDispatch(channelPrefix, suggestionId, channels, users);
}