summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCarlos Tadeu Panato Junior <ctadeu@gmail.com>2017-01-23 15:22:26 +0100
committerJoram Wilander <jwawilander@gmail.com>2017-01-23 09:22:26 -0500
commitdbfd93daa75a0998bc8645245f9cc1ad77f3cadd (patch)
tree6637a1af89dfaa64cc469f2705890c600b1dc790
parenta8f35c573875c686038d137e1663f0fd87e7f4ae (diff)
downloadchat-dbfd93daa75a0998bc8645245f9cc1ad77f3cadd.tar.gz
chat-dbfd93daa75a0998bc8645245f9cc1ad77f3cadd.tar.bz2
chat-dbfd93daa75a0998bc8645245f9cc1ad77f3cadd.zip
Move instances of Client.deleteChannel() in components to an action (#5164)
-rw-r--r--webapp/actions/channel_actions.jsx20
-rw-r--r--webapp/components/delete_channel_modal.jsx14
2 files changed, 22 insertions, 12 deletions
diff --git a/webapp/actions/channel_actions.jsx b/webapp/actions/channel_actions.jsx
index 340f90fc4..4b4e3e10c 100644
--- a/webapp/actions/channel_actions.jsx
+++ b/webapp/actions/channel_actions.jsx
@@ -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);
+ }
+ }
+ );
+}
diff --git a/webapp/components/delete_channel_modal.jsx b/webapp/components/delete_channel_modal.jsx
index 1b642861a..a6577a4a9 100644
--- a/webapp/components/delete_channel_modal.jsx
+++ b/webapp/components/delete_channel_modal.jsx
@@ -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() {