* #4697 Move instances of Client.createChannel() in components to an action
Этот коммит содержится в:
коммит произвёл
enahum
родитель
257a2234c4
Коммит
8a92908dad
@@ -275,3 +275,39 @@ export function updateChannelNotifyProps(data, success, error) {
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function createChannel(channel, success, error) {
|
||||||
|
Client.createChannel(
|
||||||
|
channel,
|
||||||
|
(data) => {
|
||||||
|
Client.getChannel(
|
||||||
|
data.id,
|
||||||
|
(data2) => {
|
||||||
|
AppDispatcher.handleServerAction({
|
||||||
|
type: ActionTypes.RECEIVED_CHANNEL,
|
||||||
|
channel: data2.channel,
|
||||||
|
member: data2.channel
|
||||||
|
});
|
||||||
|
|
||||||
|
if (success) {
|
||||||
|
success(data2);
|
||||||
|
}
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
|
AsyncClient.dispatchError(err, 'getChannel');
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
},
|
||||||
|
(err) => {
|
||||||
|
AsyncClient.dispatchError(err, 'createChannel');
|
||||||
|
|
||||||
|
if (error) {
|
||||||
|
error(err);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
// See License.txt for license information.
|
// See License.txt for license information.
|
||||||
|
|
||||||
import * as Utils from 'utils/utils.jsx';
|
import * as Utils from 'utils/utils.jsx';
|
||||||
import Client from 'client/web_client.jsx';
|
|
||||||
import TeamStore from 'stores/team_store.jsx';
|
import TeamStore from 'stores/team_store.jsx';
|
||||||
import UserStore from 'stores/user_store.jsx';
|
import UserStore from 'stores/user_store.jsx';
|
||||||
|
|
||||||
@@ -10,12 +9,9 @@ import NewChannelModal from './new_channel_modal.jsx';
|
|||||||
import ChangeURLModal from './change_url_modal.jsx';
|
import ChangeURLModal from './change_url_modal.jsx';
|
||||||
|
|
||||||
import {intlShape, injectIntl, defineMessages, FormattedMessage} from 'react-intl';
|
import {intlShape, injectIntl, defineMessages, FormattedMessage} from 'react-intl';
|
||||||
|
import {createChannel} from 'actions/channel_actions.jsx';
|
||||||
import {browserHistory} from 'react-router/es6';
|
import {browserHistory} from 'react-router/es6';
|
||||||
|
|
||||||
import AppDispatcher from '../dispatcher/app_dispatcher.jsx';
|
|
||||||
import Constants from 'utils/constants.jsx';
|
|
||||||
const ActionTypes = Constants.ActionTypes;
|
|
||||||
|
|
||||||
const SHOW_NEW_CHANNEL = 1;
|
const SHOW_NEW_CHANNEL = 1;
|
||||||
const SHOW_EDIT_URL = 2;
|
const SHOW_EDIT_URL = 2;
|
||||||
const SHOW_EDIT_URL_THEN_COMPLETE = 3;
|
const SHOW_EDIT_URL_THEN_COMPLETE = 3;
|
||||||
@@ -106,25 +102,15 @@ class NewChannelFlow extends React.Component {
|
|||||||
header: this.state.channelHeader,
|
header: this.state.channelHeader,
|
||||||
type: this.state.channelType
|
type: this.state.channelType
|
||||||
};
|
};
|
||||||
Client.createChannel(
|
|
||||||
|
createChannel(
|
||||||
channel,
|
channel,
|
||||||
(data) => {
|
(data) => {
|
||||||
Client.getChannel(
|
this.doOnModalExited = () => {
|
||||||
data.id,
|
browserHistory.push(TeamStore.getCurrentTeamRelativeUrl() + '/channels/' + data.channel.name);
|
||||||
(data2) => {
|
};
|
||||||
AppDispatcher.handleServerAction({
|
|
||||||
type: ActionTypes.RECEIVED_CHANNEL,
|
|
||||||
channel: data2.channel,
|
|
||||||
member: data2.member
|
|
||||||
});
|
|
||||||
|
|
||||||
this.doOnModalExited = () => {
|
this.props.onModalDismissed();
|
||||||
browserHistory.push(TeamStore.getCurrentTeamRelativeUrl() + '/channels/' + data2.channel.name);
|
|
||||||
};
|
|
||||||
|
|
||||||
this.props.onModalDismissed();
|
|
||||||
}
|
|
||||||
);
|
|
||||||
},
|
},
|
||||||
(err) => {
|
(err) => {
|
||||||
if (err.id === 'model.channel.is_valid.2_or_more.app_error') {
|
if (err.id === 'model.channel.is_valid.2_or_more.app_error') {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user