summaryrefslogtreecommitdiffstats
path: root/webapp/components/suggestion/switch_channel_provider.jsx
diff options
context:
space:
mode:
authorJoram Wilander <jwawilander@gmail.com>2016-10-24 14:03:56 -0400
committerenahum <nahumhbl@gmail.com>2016-10-24 15:03:56 -0300
commit3a0b0fe63fe3732a819155a97e1cc088cd22d546 (patch)
treea75e575733c99e649aeb318360936c41699d3e96 /webapp/components/suggestion/switch_channel_provider.jsx
parent4834b68ad107c29ada482f6f79c806366574ad40 (diff)
downloadchat-3a0b0fe63fe3732a819155a97e1cc088cd22d546.tar.gz
chat-3a0b0fe63fe3732a819155a97e1cc088cd22d546.tar.bz2
chat-3a0b0fe63fe3732a819155a97e1cc088cd22d546.zip
Save profiles for channel switcher autocomplete to fix switching to new DMs (#4313)
Diffstat (limited to 'webapp/components/suggestion/switch_channel_provider.jsx')
-rw-r--r--webapp/components/suggestion/switch_channel_provider.jsx14
1 files changed, 14 insertions, 0 deletions
diff --git a/webapp/components/suggestion/switch_channel_provider.jsx b/webapp/components/suggestion/switch_channel_provider.jsx
index 8921399ce..41ac0732a 100644
--- a/webapp/components/suggestion/switch_channel_provider.jsx
+++ b/webapp/components/suggestion/switch_channel_provider.jsx
@@ -4,6 +4,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';
@@ -67,6 +68,7 @@ export default class SwitchChannelProvider {
channelPrefix,
(data) => {
const users = data.in_team;
+ const currentId = UserStore.getCurrentId();
for (const id of Object.keys(allChannels)) {
const channel = allChannels[id];
@@ -75,14 +77,21 @@ export default class SwitchChannelProvider {
}
}
+ const userMap = {};
for (let i = 0; i < users.length; i++) {
const user = users[i];
+
+ if (user.id === currentId) {
+ continue;
+ }
+
const newChannel = {
display_name: user.username,
name: user.username + ' ' + Utils.localizeMessage('channel_switch_modal.dm', '(Direct Message)'),
type: Constants.DM_CHANNEL
};
channels.push(newChannel);
+ userMap[user.id] = user;
}
channels.sort((a, b) => {
@@ -107,6 +116,11 @@ export default class SwitchChannelProvider {
items: channels,
component: SwitchChannelSuggestion
});
+
+ AppDispatcher.handleServerAction({
+ type: ActionTypes.RECEIVED_PROFILES,
+ profiles: userMap
+ });
}
);
}