diff options
author | Carlos Tadeu Panato Junior <ctadeu@gmail.com> | 2017-01-19 14:40:21 +0100 |
---|---|---|
committer | Joram Wilander <jwawilander@gmail.com> | 2017-01-19 08:40:21 -0500 |
commit | 61b7226533568f3261fc233538ce998bb71a5345 (patch) | |
tree | 7068a3ce9fc9dc7bfa272112dff55ff301d84330 | |
parent | 24553164b6166e01ed27a5c5de476d73c6369461 (diff) | |
download | chat-61b7226533568f3261fc233538ce998bb71a5345.tar.gz chat-61b7226533568f3261fc233538ce998bb71a5345.tar.bz2 chat-61b7226533568f3261fc233538ce998bb71a5345.zip |
Move instances of Client.updateChannelPurpose() in components to an action (#5096)
-rw-r--r-- | webapp/actions/channel_actions.jsx | 19 | ||||
-rw-r--r-- | webapp/components/edit_channel_purpose_modal.jsx | 16 |
2 files changed, 23 insertions, 12 deletions
diff --git a/webapp/actions/channel_actions.jsx b/webapp/actions/channel_actions.jsx index 3e41a2310..c9c04d462 100644 --- a/webapp/actions/channel_actions.jsx +++ b/webapp/actions/channel_actions.jsx @@ -364,6 +364,25 @@ export function createChannel(channel, success, error) { ); } +export function updateChannelPurpose(channelId, purposeValue, success, error) { + Client.updateChannelPurpose( + channelId, + purposeValue, + () => { + AsyncClient.getChannel(channelId); + + if (success) { + success(); + } + }, + (err) => { + if (error) { + error(err); + } + } + ); +} + export function updateChannelHeader(channelId, header, success, error) { Client.updateChannelHeader( channelId, diff --git a/webapp/components/edit_channel_purpose_modal.jsx b/webapp/components/edit_channel_purpose_modal.jsx index 21bf013a9..4bb876460 100644 --- a/webapp/components/edit_channel_purpose_modal.jsx +++ b/webapp/components/edit_channel_purpose_modal.jsx @@ -2,15 +2,14 @@ // See License.txt for license information. import PreferenceStore from 'stores/preference_store.jsx'; -import AppDispatcher from '../dispatcher/app_dispatcher.jsx'; -import * as AsyncClient from 'utils/async_client.jsx'; -import Client from 'client/web_client.jsx'; + import Constants from 'utils/constants.jsx'; import * as Utils from 'utils/utils.jsx'; import React from 'react'; import {Modal} from 'react-bootstrap'; import {FormattedMessage} from 'react-intl'; +import {updateChannelPurpose} from 'actions/channel_actions.jsx'; export default class EditChannelPurposeModal extends React.Component { constructor(props) { @@ -64,18 +63,11 @@ export default class EditChannelPurposeModal extends React.Component { this.setState({submitted: true}); - Client.updateChannelPurpose( + updateChannelPurpose( this.props.channel.id, this.refs.purpose.value.trim(), - (channel) => { - AsyncClient.getChannel(this.props.channel.id); - + () => { this.handleHide(); - - AppDispatcher.handleServerAction({ - type: Constants.ActionTypes.RECEIVED_CHANNEL, - channel - }); }, (err) => { if (err.id === 'api.context.invalid_param.app_error') { |