diff options
author | Carlos Tadeu Panato Junior <ctadeu@gmail.com> | 2017-01-17 21:49:58 +0100 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-01-17 15:49:58 -0500 |
commit | 8f0175e15c4d6bd08ca6795851455468811c3dc9 (patch) | |
tree | c1fd3db6cdfc9c380d39bf1f1a6fd6ca2ffaa145 | |
parent | a5b5dabf4a150b78f5f937a7d287b24d5b8d0647 (diff) | |
download | chat-8f0175e15c4d6bd08ca6795851455468811c3dc9.tar.gz chat-8f0175e15c4d6bd08ca6795851455468811c3dc9.tar.bz2 chat-8f0175e15c4d6bd08ca6795851455468811c3dc9.zip |
Move instances of Client.updateChannelHeader() in components to an action (#5098)
-rw-r--r-- | webapp/actions/channel_actions.jsx | 22 | ||||
-rw-r--r-- | webapp/components/edit_channel_header_modal.jsx | 12 |
2 files changed, 25 insertions, 9 deletions
diff --git a/webapp/actions/channel_actions.jsx b/webapp/actions/channel_actions.jsx index 6cf8449f0..40e0cde30 100644 --- a/webapp/actions/channel_actions.jsx +++ b/webapp/actions/channel_actions.jsx @@ -321,3 +321,25 @@ export function createChannel(channel, success, error) { } ); } + +export function updateChannelHeader(channelId, header, success, error) { + Client.updateChannelHeader( + channelId, + header, + (channelData) => { + AppDispatcher.handleServerAction({ + type: ActionTypes.RECEIVED_CHANNEL, + channel: channelData + }); + + if (success) { + success(channelData); + } + }, + (err) => { + if (error) { + error(err); + } + } + ); +} diff --git a/webapp/components/edit_channel_header_modal.jsx b/webapp/components/edit_channel_header_modal.jsx index 490b9fb31..0d8eb8acb 100644 --- a/webapp/components/edit_channel_header_modal.jsx +++ b/webapp/components/edit_channel_header_modal.jsx @@ -2,13 +2,12 @@ // See License.txt for license information. import ReactDOM from 'react-dom'; -import AppDispatcher from '../dispatcher/app_dispatcher.jsx'; -import Client from 'client/web_client.jsx'; import Constants from 'utils/constants.jsx'; import * as Utils from 'utils/utils.jsx'; import PreferenceStore from 'stores/preference_store.jsx'; import {intlShape, injectIntl, defineMessages, FormattedMessage} from 'react-intl'; +import {updateChannelHeader} from 'actions/channel_actions.jsx'; import {Modal} from 'react-bootstrap'; @@ -64,17 +63,12 @@ class EditChannelHeaderModal extends React.Component { handleSubmit() { this.setState({submitted: true}); - Client.updateChannelHeader( + updateChannelHeader( this.props.channel.id, this.state.header, - (channel) => { + () => { this.setState({serverError: ''}); this.onHide(); - - AppDispatcher.handleServerAction({ - type: Constants.ActionTypes.RECEIVED_CHANNEL, - channel - }); }, (err) => { if (err.id === 'api.context.invalid_param.app_error') { |