From 3a0b0fe63fe3732a819155a97e1cc088cd22d546 Mon Sep 17 00:00:00 2001 From: Joram Wilander Date: Mon, 24 Oct 2016 14:03:56 -0400 Subject: Save profiles for channel switcher autocomplete to fix switching to new DMs (#4313) --- webapp/components/suggestion/switch_channel_provider.jsx | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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 + }); } ); } -- cgit v1.2.3-1-g7c22