Move instances of Client.deleteChannel() in components to an action (#5164)

This commit is contained in:
Carlos Tadeu Panato Junior
2017-01-23 15:22:26 +01:00
committed by Joram Wilander
parent a8f35c5738
commit dbfd93daa7
2 changed files with 22 additions and 12 deletions

View File

@@ -461,3 +461,23 @@ export function leaveChannel(channelId, success, error) {
}
);
}
export function deleteChannel(channelId, success, error) {
Client.deleteChannel(
channelId,
() => {
loadChannelsForCurrentUser();
if (success) {
success();
}
},
(err) => {
AsyncClient.dispatchError(err, 'handleDelete');
if (error) {
error(err);
}
}
);
}

View File

@@ -1,8 +1,6 @@
// Copyright (c) 2015 Mattermost, Inc. All Rights Reserved.
// See License.txt for license information.
import * as AsyncClient from 'utils/async_client.jsx';
import Client from 'client/web_client.jsx';
import {Modal} from 'react-bootstrap';
import TeamStore from 'stores/team_store.jsx';
import Constants from 'utils/constants.jsx';
@@ -13,7 +11,7 @@ import {browserHistory} from 'react-router/es6';
import React from 'react';
import {loadChannelsForCurrentUser} from 'actions/channel_actions.jsx';
import {deleteChannel} from 'actions/channel_actions.jsx';
export default class DeleteChannelModal extends React.Component {
constructor(props) {
@@ -31,15 +29,7 @@ export default class DeleteChannelModal extends React.Component {
}
browserHistory.push(TeamStore.getCurrentTeamRelativeUrl() + '/channels/town-square');
Client.deleteChannel(
this.props.channel.id,
() => {
loadChannelsForCurrentUser();
},
(err) => {
AsyncClient.dispatchError(err, 'handleDelete');
}
);
deleteChannel(this.props.channel.id);
}
onHide() {