summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorhmhealey <harrisonmhealey@gmail.com>2016-02-05 09:47:43 -0500
committerhmhealey <harrisonmhealey@gmail.com>2016-02-05 10:21:53 -0500
commite6a7594d70dfde30e3dbb36d45e5d1458883553f (patch)
tree1ec97e6a2710a0acf8f3a713876a9bc1dcd28748 /web
parent8e79f12f3c6c0f8858addaf6f66ea6e88a965b65 (diff)
downloadchat-e6a7594d70dfde30e3dbb36d45e5d1458883553f.tar.gz
chat-e6a7594d70dfde30e3dbb36d45e5d1458883553f.tar.bz2
chat-e6a7594d70dfde30e3dbb36d45e5d1458883553f.zip
Changed CommandProvider to only set the matched pretext if it actually matches anything
Diffstat (limited to 'web')
-rw-r--r--web/react/components/suggestion/command_provider.jsx3
-rw-r--r--web/react/stores/suggestion_store.jsx4
-rw-r--r--web/react/utils/async_client.jsx18
3 files changed, 13 insertions, 12 deletions
diff --git a/web/react/components/suggestion/command_provider.jsx b/web/react/components/suggestion/command_provider.jsx
index 91d556bb9..09c9b9982 100644
--- a/web/react/components/suggestion/command_provider.jsx
+++ b/web/react/components/suggestion/command_provider.jsx
@@ -2,7 +2,6 @@
// See License.txt for license information.
import * as AsyncClient from '../../utils/async_client.jsx';
-import SuggestionStore from '../../stores/suggestion_store.jsx';
class CommandSuggestion extends React.Component {
render() {
@@ -38,8 +37,6 @@ CommandSuggestion.propTypes = {
export default class CommandProvider {
handlePretextChanged(suggestionId, pretext) {
if (pretext.startsWith('/')) {
- SuggestionStore.setMatchedPretext(suggestionId, pretext);
-
AsyncClient.getSuggestedCommands(pretext, suggestionId, CommandSuggestion);
}
}
diff --git a/web/react/stores/suggestion_store.jsx b/web/react/stores/suggestion_store.jsx
index 9cd566c22..dd5c107e0 100644
--- a/web/react/stores/suggestion_store.jsx
+++ b/web/react/stores/suggestion_store.jsx
@@ -223,7 +223,9 @@ class SuggestionStore extends EventEmitter {
this.emitSuggestionsChanged(id);
break;
case ActionTypes.SUGGESTION_RECEIVED_SUGGESTIONS:
- if (other.matchedPretext === this.getMatchedPretext(id)) {
+ if (this.getMatchedPretext(id) === '') {
+ this.setMatchedPretext(id, other.matchedPretext);
+
// ensure the matched pretext hasn't changed so that we don't receive suggestions for outdated pretext
this.addSuggestions(id, other.terms, other.items, other.component);
diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx
index 328a7a7f2..c5957e8cc 100644
--- a/web/react/utils/async_client.jsx
+++ b/web/react/utils/async_client.jsx
@@ -789,14 +789,16 @@ export function getSuggestedCommands(command, suggestionId, component) {
// pull out the suggested commands from the returned data
const terms = matches.map((suggestion) => suggestion.suggestion);
- AppDispatcher.handleServerAction({
- type: ActionTypes.SUGGESTION_RECEIVED_SUGGESTIONS,
- id: suggestionId,
- matchedPretext: command,
- terms,
- items: matches,
- component
- });
+ if (terms.length > 0) {
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.SUGGESTION_RECEIVED_SUGGESTIONS,
+ id: suggestionId,
+ matchedPretext: command,
+ terms,
+ items: matches,
+ component
+ });
+ }
},
(err) => {
dispatchError(err, 'getCommandSuggestions');