summaryrefslogtreecommitdiffstats
path: root/web/react/utils/async_client.jsx
diff options
context:
space:
mode:
authorHarrison Healey <harrisonmhealey@gmail.com>2016-02-04 11:38:27 -0500
committerHarrison Healey <harrisonmhealey@gmail.com>2016-02-04 11:38:27 -0500
commit4f1dbb8ca9a6cce09c9a20e91e074feaadd755a8 (patch)
treed5811b516ef8b826e6ccd80efdf72c6fe52157a2 /web/react/utils/async_client.jsx
parent852acf1bb2818316e40012a385a5e8bec287eb05 (diff)
parentdffc5323ecd9c7bc1af0ea06ef4827078f9bcd52 (diff)
downloadchat-4f1dbb8ca9a6cce09c9a20e91e074feaadd755a8.tar.gz
chat-4f1dbb8ca9a6cce09c9a20e91e074feaadd755a8.tar.bz2
chat-4f1dbb8ca9a6cce09c9a20e91e074feaadd755a8.zip
Merge pull request #2052 from mattermost/PLT-1429
PLT-1429 adding user created slash commands
Diffstat (limited to 'web/react/utils/async_client.jsx')
-rw-r--r--web/react/utils/async_client.jsx19
1 files changed, 13 insertions, 6 deletions
diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx
index d615e02c7..328a7a7f2 100644
--- a/web/react/utils/async_client.jsx
+++ b/web/react/utils/async_client.jsx
@@ -774,20 +774,27 @@ export function savePreferences(preferences, success, error) {
}
export function getSuggestedCommands(command, suggestionId, component) {
- client.executeCommand(
- '',
- command,
- true,
+ client.listCommands(
(data) => {
+ var matches = [];
+ data.forEach((cmd) => {
+ if (('/' + cmd.trigger).indexOf(command) === 0) {
+ matches.push({
+ suggestion: '/' + cmd.trigger + ' ' + cmd.auto_complete_hint,
+ description: cmd.auto_complete_desc
+ });
+ }
+ });
+
// pull out the suggested commands from the returned data
- const terms = data.suggestions.map((suggestion) => suggestion.suggestion);
+ const terms = matches.map((suggestion) => suggestion.suggestion);
AppDispatcher.handleServerAction({
type: ActionTypes.SUGGESTION_RECEIVED_SUGGESTIONS,
id: suggestionId,
matchedPretext: command,
terms,
- items: data.suggestions,
+ items: matches,
component
});
},