summaryrefslogtreecommitdiffstats
path: root/webapp/components/channel_switch_modal.jsx
diff options
context:
space:
mode:
authorenahum <nahumhbl@gmail.com>2016-12-08 12:20:03 -0300
committerHarrison Healey <harrisonmhealey@gmail.com>2016-12-08 10:20:03 -0500
commitb57c9fec89f736de8622218d6dc779012a266a91 (patch)
treef56ba6e73f7b6e7b2177231a7532cc40d7422e30 /webapp/components/channel_switch_modal.jsx
parentc4974374d9840caa6ec496c138a6220dd40afa54 (diff)
downloadchat-b57c9fec89f736de8622218d6dc779012a266a91.tar.gz
chat-b57c9fec89f736de8622218d6dc779012a266a91.tar.bz2
chat-b57c9fec89f736de8622218d6dc779012a266a91.zip
PLT-4894 channel switcher (CTRL+K) to match message autocomplete (#4733)
* PLT-4894 Change name display of direct messages in channel switcher (CTRL+K) to match message autocomplete * Addressing feedback
Diffstat (limited to 'webapp/components/channel_switch_modal.jsx')
-rw-r--r--webapp/components/channel_switch_modal.jsx16
1 files changed, 9 insertions, 7 deletions
diff --git a/webapp/components/channel_switch_modal.jsx b/webapp/components/channel_switch_modal.jsx
index 063962a18..674725d88 100644
--- a/webapp/components/channel_switch_modal.jsx
+++ b/webapp/components/channel_switch_modal.jsx
@@ -24,6 +24,7 @@ export default class SwitchChannelModal extends React.Component {
super();
this.onChange = this.onChange.bind(this);
+ this.onItemSelected = this.onItemSelected.bind(this);
this.onShow = this.onShow.bind(this);
this.onHide = this.onHide.bind(this);
this.onExited = this.onExited.bind(this);
@@ -72,6 +73,10 @@ export default class SwitchChannelModal extends React.Component {
this.setState({text: e.target.value});
}
+ onItemSelected(item) {
+ this.selected = item;
+ }
+
handleKeyDown(e) {
this.setState({
error: ''
@@ -82,13 +87,10 @@ export default class SwitchChannelModal extends React.Component {
}
handleSubmit() {
- const name = this.state.text.trim();
let channel = null;
- // TODO: Replace this hack with something reasonable
- if (name.indexOf(Utils.localizeMessage('channel_switch_modal.dm', '(Direct Message)')) > 0) {
- const dmUsername = name.substr(0, name.indexOf(Utils.localizeMessage('channel_switch_modal.dm', '(Direct Message)')) - 1);
- const user = UserStore.getProfileByUsername(dmUsername);
+ if (this.selected.type === Constants.DM_CHANNEL) {
+ const user = UserStore.getProfileByUsername(this.selected.name);
if (user) {
openDirectChannelToUser(
@@ -104,7 +106,7 @@ export default class SwitchChannelModal extends React.Component {
);
}
} else {
- channel = ChannelStore.getByName(this.state.text.trim());
+ channel = ChannelStore.getByName(this.selected.name);
this.switchToChannel(channel);
}
}
@@ -155,10 +157,10 @@ export default class SwitchChannelModal extends React.Component {
onChange={this.onChange}
value={this.state.text}
onKeyDown={this.handleKeyDown}
+ onItemSelected={this.onItemSelected}
listComponent={SuggestionList}
maxLength='64'
providers={this.suggestionProviders}
- preventDefaultSubmit={false}
listStyle='bottom'
/>
</Modal.Body>