summaryrefslogtreecommitdiffstats
path: root/webapp
diff options
context:
space:
mode:
Diffstat (limited to 'webapp')
-rw-r--r--webapp/actions/user_actions.jsx18
-rw-r--r--webapp/client/client.jsx11
-rw-r--r--webapp/components/suggestion/switch_channel_provider.jsx7
-rw-r--r--webapp/tests/client_user.test.jsx15
4 files changed, 46 insertions, 5 deletions
diff --git a/webapp/actions/user_actions.jsx b/webapp/actions/user_actions.jsx
index ce2246d30..455ca1730 100644
--- a/webapp/actions/user_actions.jsx
+++ b/webapp/actions/user_actions.jsx
@@ -318,6 +318,24 @@ export function autocompleteUsersInTeam(username, success, error) {
);
}
+export function autocompleteUsers(username, success, error) {
+ Client.autocompleteUsers(
+ username,
+ (data) => {
+ if (success) {
+ success(data);
+ }
+ },
+ (err) => {
+ AsyncClient.dispatchError(err, 'autocompleteUsers');
+
+ if (error) {
+ error(err);
+ }
+ }
+ );
+}
+
export function updateUser(username, success, error) {
Client.updateUser(
username,
diff --git a/webapp/client/client.jsx b/webapp/client/client.jsx
index 38cc2f111..ff42fb7ac 100644
--- a/webapp/client/client.jsx
+++ b/webapp/client/client.jsx
@@ -1112,7 +1112,7 @@ export default class Client {
set(this.defaultHeaders).
type('application/json').
accept('application/json').
- end(this.handleResponse.bind(this, 'autocompleteUsers', success, error));
+ end(this.handleResponse.bind(this, 'autocompleteUsersInChannel', success, error));
}
autocompleteUsersInTeam(term, success, error) {
@@ -1121,6 +1121,15 @@ export default class Client {
set(this.defaultHeaders).
type('application/json').
accept('application/json').
+ end(this.handleResponse.bind(this, 'autocompleteUsersInTeam', success, error));
+ }
+
+ autocompleteUsers(term, success, error) {
+ request.
+ get(`${this.getUsersRoute()}/autocomplete?term=${encodeURIComponent(term)}`).
+ set(this.defaultHeaders).
+ type('application/json').
+ accept('application/json').
end(this.handleResponse.bind(this, 'autocompleteUsers', success, error));
}
diff --git a/webapp/components/suggestion/switch_channel_provider.jsx b/webapp/components/suggestion/switch_channel_provider.jsx
index 8178722ef..534a7e30f 100644
--- a/webapp/components/suggestion/switch_channel_provider.jsx
+++ b/webapp/components/suggestion/switch_channel_provider.jsx
@@ -6,7 +6,7 @@ import Suggestion from './suggestion.jsx';
import ChannelStore from 'stores/channel_store.jsx';
import UserStore from 'stores/user_store.jsx';
-import {autocompleteUsersInTeam} from 'actions/user_actions.jsx';
+import {autocompleteUsers} from 'actions/user_actions.jsx';
import AppDispatcher from 'dispatcher/app_dispatcher.jsx';
import {Constants, ActionTypes} from 'utils/constants.jsx';
@@ -64,10 +64,9 @@ export default class SwitchChannelProvider {
const channels = [];
function autocomplete() {
- autocompleteUsersInTeam(
+ autocompleteUsers(
channelPrefix,
- (data) => {
- const users = data.in_team;
+ (users) => {
const currentId = UserStore.getCurrentId();
for (const id of Object.keys(allChannels)) {
diff --git a/webapp/tests/client_user.test.jsx b/webapp/tests/client_user.test.jsx
index 2e5b80dd7..5e5eb6821 100644
--- a/webapp/tests/client_user.test.jsx
+++ b/webapp/tests/client_user.test.jsx
@@ -602,6 +602,21 @@ describe('Client.User', function() {
});
});
+ it('autocompleteUsers', function(done) {
+ TestHelper.initBasic(() => {
+ TestHelper.basicClient().autocompleteUsers(
+ 'uid',
+ function(data) {
+ assert.equal(data != null, true);
+ done();
+ },
+ function(err) {
+ done(new Error(err.message));
+ }
+ );
+ });
+ });
+
it('getStatusesByIds', function(done) {
TestHelper.initBasic(() => {
var ids = [];