Skip to content

Commit

Permalink
Fixing opening a GM with the channel switcher. (mattermost#2047)
Browse files Browse the repository at this point in the history
  • Loading branch information
crspeller committed Nov 20, 2018
1 parent 4453f86 commit 42ea16b
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions components/quick_switch_modal/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';

import {switchToChannel} from 'actions/views/channel';
import {switchToChannelById} from 'actions/views/channel';

import QuickSwitchModal from './quick_switch_modal.jsx';

Expand All @@ -17,7 +17,7 @@ function mapStateToProps() {
function mapDispatchToProps(dispatch) {
return {
actions: bindActionCreators({
switchToChannel,
switchToChannelById,
}, dispatch),
};
}
Expand Down
4 changes: 2 additions & 2 deletions components/quick_switch_modal/quick_switch_modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export default class QuickSwitchModal extends React.PureComponent {
showTeamSwitcher: PropTypes.bool,

actions: PropTypes.shape({
switchToChannel: PropTypes.func.isRequired,
switchToChannelById: PropTypes.func.isRequired,
}).isRequired,
}

Expand Down Expand Up @@ -131,7 +131,7 @@ export default class QuickSwitchModal extends React.PureComponent {

if (this.state.mode === CHANNEL_MODE) {
const selectedChannel = selected.channel;
this.props.actions.switchToChannel(selectedChannel).then((result) => {
this.props.actions.switchToChannelById(selectedChannel.id).then((result) => {
if (result.data) {
this.onHide();
}
Expand Down
10 changes: 5 additions & 5 deletions components/quick_switch_modal/quick_switch_modal.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe('components/QuickSwitchModal', () => {
onHide: jest.fn(),
showTeamSwitcher: false,
actions: {
switchToChannel: jest.fn().mockImplementation(() => {
switchToChannelById: jest.fn().mockImplementation(() => {
const error = {
message: 'Failed',
};
Expand All @@ -42,7 +42,7 @@ describe('components/QuickSwitchModal', () => {

wrapper.instance().handleSubmit();
expect(baseProps.onHide).not.toBeCalled();
expect(props.actions.switchToChannel).not.toBeCalled();
expect(props.actions.switchToChannelById).not.toBeCalled();
});

it('should fail to switch to a channel', (done) => {
Expand All @@ -52,7 +52,7 @@ describe('components/QuickSwitchModal', () => {

const channel = {id: 'channel_id', userId: 'user_id', type: Constants.DM_CHANNEL};
wrapper.instance().handleSubmit({channel});
expect(baseProps.actions.switchToChannel).toBeCalledWith(channel);
expect(baseProps.actions.switchToChannelById).toBeCalledWith(channel.id);
process.nextTick(() => {
expect(baseProps.onHide).not.toBeCalled();
done();
Expand All @@ -63,7 +63,7 @@ describe('components/QuickSwitchModal', () => {
const props = {
...baseProps,
actions: {
switchToChannel: jest.fn().mockImplementation(() => {
switchToChannelById: jest.fn().mockImplementation(() => {
const data = true;
return Promise.resolve({data});
}),
Expand All @@ -76,7 +76,7 @@ describe('components/QuickSwitchModal', () => {

const channel = {id: 'channel_id', userId: 'user_id', type: Constants.DM_CHANNEL};
wrapper.instance().handleSubmit({channel});
expect(props.actions.switchToChannel).toBeCalledWith(channel);
expect(props.actions.switchToChannelById).toBeCalledWith(channel.id);
process.nextTick(() => {
expect(baseProps.onHide).toBeCalled();
done();
Expand Down

0 comments on commit 42ea16b

Please sign in to comment.