mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
Move instances of Client.deleteChannel() in components to an action (#5164)
This commit is contained in:
committed by
Joram Wilander
parent
a8f35c5738
commit
dbfd93daa7
@@ -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);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user