summaryrefslogtreecommitdiffstats
path: root/webapp/components/channel_switch_modal.jsx
diff options
context:
space:
mode:
Diffstat (limited to 'webapp/components/channel_switch_modal.jsx')
-rw-r--r--webapp/components/channel_switch_modal.jsx32
1 files changed, 6 insertions, 26 deletions
diff --git a/webapp/components/channel_switch_modal.jsx b/webapp/components/channel_switch_modal.jsx
index ec257bab5..7d15a9c45 100644
--- a/webapp/components/channel_switch_modal.jsx
+++ b/webapp/components/channel_switch_modal.jsx
@@ -8,12 +8,13 @@ import SwitchChannelProvider from './suggestion/switch_channel_provider.jsx';
import {FormattedMessage} from 'react-intl';
import {Modal} from 'react-bootstrap';
+import {goToChannel, openDirectChannelToUser} from 'actions/channel_actions.jsx';
+
import ChannelStore from 'stores/channel_store.jsx';
import UserStore from 'stores/user_store.jsx';
import Constants from 'utils/constants.jsx';
import * as Utils from 'utils/utils.jsx';
-import * as ChannelActions from 'actions/channel_actions.jsx';
import React from 'react';
import $ from 'jquery';
@@ -27,30 +28,14 @@ export default class SwitchChannelModal extends React.Component {
this.onExited = this.onExited.bind(this);
this.handleKeyDown = this.handleKeyDown.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
- this.handleDmUserChange = this.handleDmUserChange.bind(this);
this.suggestionProviders = [new SwitchChannelProvider()];
this.state = {
- dmUsers: UserStore.getDirectProfiles(),
text: '',
error: ''
};
}
- componentDidMount() {
- UserStore.addDmListChangeListener(this.handleDmUserChange);
- }
-
- componentWillUnmount() {
- UserStore.removeDmListChangeListener(this.handleDmUserChange);
- }
-
- handleDmUserChange() {
- this.setState({
- dmUsers: UserStore.getDirectProfiles()
- });
- }
-
componentDidUpdate(prevProps) {
if (this.props.show && !prevProps.show) {
const textbox = this.refs.search.getTextbox();
@@ -97,18 +82,13 @@ export default class SwitchChannelModal extends React.Component {
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);
- let user = null;
- for (const id in this.state.dmUsers) {
- if (this.state.dmUsers[id].username === dmUsername) {
- user = this.state.dmUsers[id];
- break;
- }
- }
+ const user = UserStore.getProfileByUsername(dmUsername);
if (user) {
- Utils.openDirectChannelToUser(
+ openDirectChannelToUser(
user,
(ch) => {
channel = ch;
@@ -123,7 +103,7 @@ export default class SwitchChannelModal extends React.Component {
}
if (channel !== null) {
- ChannelActions.goToChannel(channel);
+ goToChannel(channel);
this.onHide();
} else if (this.state.text !== '') {
this.setState({