summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
author=Corey Hulen <corey@hulen.com>2016-01-08 12:41:26 -0600
committer=Corey Hulen <corey@hulen.com>2016-01-08 12:41:26 -0600
commit3fba8e42b140c1189bf3c06882cce5e2231e63da (patch)
tree7a0721cecf6624fc9c1fd71449628472b941ddeb /web
parent001a4448ca5fb0018eeb442915b473b121c04bf3 (diff)
downloadchat-3fba8e42b140c1189bf3c06882cce5e2231e63da.tar.gz
chat-3fba8e42b140c1189bf3c06882cce5e2231e63da.tar.bz2
chat-3fba8e42b140c1189bf3c06882cce5e2231e63da.zip
partial fix for UI
Diffstat (limited to 'web')
-rw-r--r--web/react/components/create_post.jsx7
-rw-r--r--web/react/utils/async_client.jsx20
-rw-r--r--web/react/utils/client.jsx16
3 files changed, 30 insertions, 13 deletions
diff --git a/web/react/components/create_post.jsx b/web/react/components/create_post.jsx
index e901b272a..72bf83e43 100644
--- a/web/react/components/create_post.jsx
+++ b/web/react/components/create_post.jsx
@@ -134,15 +134,10 @@ export default class CreatePost extends React.Component {
post.message,
false,
(data) => {
- if (data.response === 'not implemented') {
- this.sendMessage(post);
- return;
- }
-
PostStore.storeDraft(data.channel_id, null);
this.setState({messageText: '', submitting: false, postError: null, previews: [], serverError: null});
- if (data.goto_location.length > 0) {
+ if (data.goto_location && data.goto_location.length > 0) {
window.location.href = data.goto_location;
}
},
diff --git a/web/react/utils/async_client.jsx b/web/react/utils/async_client.jsx
index f218270da..78be646ac 100644
--- a/web/react/utils/async_client.jsx
+++ b/web/react/utils/async_client.jsx
@@ -747,20 +747,28 @@ 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.trigger);
+ 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
});
},
diff --git a/web/react/utils/client.jsx b/web/react/utils/client.jsx
index e1c331aff..56c8c4b3e 100644
--- a/web/react/utils/client.jsx
+++ b/web/react/utils/client.jsx
@@ -839,7 +839,7 @@ export function getChannelExtraInfo(id, success, error) {
export function executeCommand(channelId, command, suggest, success, error) {
$.ajax({
- url: '/api/v1/command',
+ url: '/api/v1/commands/execute',
dataType: 'json',
contentType: 'application/json',
type: 'POST',
@@ -852,6 +852,20 @@ export function executeCommand(channelId, command, suggest, success, error) {
});
}
+export function listCommands(success, error) {
+ $.ajax({
+ url: '/api/v1/commands/list',
+ dataType: 'json',
+ contentType: 'application/json',
+ type: 'POST',
+ success,
+ error: function onError(xhr, status, err) {
+ var e = handleError('listCommands', xhr, status, err);
+ error(e);
+ }
+ });
+}
+
export function getPostsPage(channelId, offset, limit, success, error, complete) {
$.ajax({
cache: false,