summaryrefslogtreecommitdiffstats
path: root/webapp/components/suggestion
diff options
context:
space:
mode:
authorDavid Lu <david.lu@hotmail.com>2016-06-06 10:54:23 -0700
committerJoram Wilander <jwawilander@gmail.com>2016-06-06 13:54:23 -0400
commitea99cedb62a308415d9558badaf638abda73dbc8 (patch)
treeadf3836560bc4764fa6ebbfe21b7543d4a1c8dfa /webapp/components/suggestion
parent26ec73d5d215f37bb0446f4721ccfea3c9f56f89 (diff)
downloadchat-ea99cedb62a308415d9558badaf638abda73dbc8.tar.gz
chat-ea99cedb62a308415d9558badaf638abda73dbc8.tar.bz2
chat-ea99cedb62a308415d9558badaf638abda73dbc8.zip
PLT-3185 Added support for DMs in Channel Switcher (#3260)
* Added support for DMs * Checked username beginning characters
Diffstat (limited to 'webapp/components/suggestion')
-rw-r--r--webapp/components/suggestion/switch_channel_provider.jsx17
1 files changed, 16 insertions, 1 deletions
diff --git a/webapp/components/suggestion/switch_channel_provider.jsx b/webapp/components/suggestion/switch_channel_provider.jsx
index b52cd7fe9..c12918c51 100644
--- a/webapp/components/suggestion/switch_channel_provider.jsx
+++ b/webapp/components/suggestion/switch_channel_provider.jsx
@@ -6,6 +6,8 @@ import React from 'react';
import ChannelStore from 'stores/channel_store.jsx';
import SuggestionStore from 'stores/suggestion_store.jsx';
import Suggestion from './suggestion.jsx';
+import Constants from 'utils/constants.jsx';
+import * as Utils from 'utils/utils.jsx';
class SwitchChannelSuggestion extends Suggestion {
render() {
@@ -16,7 +18,12 @@ class SwitchChannelSuggestion extends Suggestion {
className += ' suggestion--selected';
}
- const displayName = item.display_name + ' (' + item.name + ')';
+ let displayName = '';
+ if (item.type === Constants.DM_CHANNEL) {
+ displayName = item.display_name + ' ' + Utils.localizeMessage('channel_switch_modal.dm', '(Direct Message)');
+ } else {
+ displayName = item.display_name + ' (' + item.name + ')';
+ }
return (
<div
@@ -39,6 +46,14 @@ export default class SwitchChannelProvider {
const channel = allChannels[id];
if (channel.display_name.toLowerCase().startsWith(channelPrefix.toLowerCase())) {
channels.push(channel);
+ } else if (channel.type === Constants.DM_CHANNEL && Utils.getDirectTeammate(channel.id).username.startsWith(channelPrefix.toLowerCase())) {
+ // New channel to not modify existing channel
+ const newChannel = {
+ display_name: Utils.getDirectTeammate(channel.id).username,
+ name: Utils.getDirectTeammate(channel.id).username + ' ' + Utils.localizeMessage('channel_switch_modal.dm', '(Direct Message)'),
+ type: Constants.DM_CHANNEL
+ };
+ channels.push(newChannel);
}
}