diff options
author | Carlos Tadeu Panato Junior <ctadeu@gmail.com> | 2017-01-20 15:45:22 +0100 |
---|---|---|
committer | Christopher Speller <crspeller@gmail.com> | 2017-01-20 09:45:22 -0500 |
commit | 6097f93704862215791ce8855c31471e40ef0af1 (patch) | |
tree | 54af846802d2f16f9b3d4466b455e5618b81c19d /webapp/components | |
parent | e8d7701b60e8285568ed01c2fe155ed02c388136 (diff) | |
download | chat-6097f93704862215791ce8855c31471e40ef0af1.tar.gz chat-6097f93704862215791ce8855c31471e40ef0af1.tar.bz2 chat-6097f93704862215791ce8855c31471e40ef0af1.zip |
Move instances of Client.leaveChannel() in components to an action (#5131)
* Move instances of Client.leaveChannel() in components to an action
* create isFavoriteChannelId
Diffstat (limited to 'webapp/components')
-rw-r--r-- | webapp/components/channel_header.jsx | 19 | ||||
-rw-r--r-- | webapp/components/navbar.jsx | 22 |
2 files changed, 3 insertions, 38 deletions
diff --git a/webapp/components/channel_header.jsx b/webapp/components/channel_header.jsx index fc0ec132e..12f9fb6c6 100644 --- a/webapp/components/channel_header.jsx +++ b/webapp/components/channel_header.jsx @@ -29,15 +29,12 @@ import * as ChannelActions from 'actions/channel_actions.jsx'; import * as Utils from 'utils/utils.jsx'; import * as ChannelUtils from 'utils/channel_utils.jsx'; import * as TextFormatting from 'utils/text_formatting.jsx'; -import Client from 'client/web_client.jsx'; -import * as AsyncClient from 'utils/async_client.jsx'; import {getFlaggedPosts} from 'actions/post_actions.jsx'; import {Constants, Preferences, UserStatuses} from 'utils/constants.jsx'; import React from 'react'; import {FormattedMessage} from 'react-intl'; -import {browserHistory} from 'react-router/es6'; import {Tooltip, OverlayTrigger, Popover} from 'react-bootstrap'; const PreReleaseFeatures = Constants.PRE_RELEASE_FEATURES; @@ -131,21 +128,7 @@ export default class ChannelHeader extends React.Component { } handleLeave() { - Client.leaveChannel(this.state.channel.id, - () => { - const channelId = this.state.channel.id; - - if (this.state.isFavorite) { - ChannelActions.unmarkFavorite(channelId); - } - - const townsquare = ChannelStore.getByName('town-square'); - browserHistory.push(TeamStore.getCurrentTeamRelativeUrl() + '/channels/' + townsquare.name); - }, - (err) => { - AsyncClient.dispatchError(err, 'handleLeave'); - } - ); + ChannelActions.leaveChannel(this.state.channel.id); } toggleFavorite = (e) => { diff --git a/webapp/components/navbar.jsx b/webapp/components/navbar.jsx index 338d4edd1..b54b8701e 100644 --- a/webapp/components/navbar.jsx +++ b/webapp/components/navbar.jsx @@ -22,8 +22,6 @@ import PreferenceStore from 'stores/preference_store.jsx'; import ChannelSwitchModal from './channel_switch_modal.jsx'; -import Client from 'client/web_client.jsx'; -import * as AsyncClient from 'utils/async_client.jsx'; import * as Utils from 'utils/utils.jsx'; import * as ChannelUtils from 'utils/channel_utils.jsx'; import * as ChannelActions from 'actions/channel_actions.jsx'; @@ -37,7 +35,7 @@ import {FormattedMessage} from 'react-intl'; import {Popover, OverlayTrigger} from 'react-bootstrap'; -import {Link, browserHistory} from 'react-router/es6'; +import {Link} from 'react-router/es6'; import React from 'react'; @@ -111,23 +109,7 @@ export default class Navbar extends React.Component { } handleLeave() { - var channelId = this.state.channel.id; - - Client.leaveChannel(channelId, - () => { - ChannelActions.loadChannelsForCurrentUser(); - - if (this.state.isFavorite) { - ChannelActions.unmarkFavorite(channelId); - } - - const townsquare = ChannelStore.getByName('town-square'); - browserHistory.push(TeamStore.getCurrentTeamRelativeUrl() + '/channels/' + townsquare.name); - }, - (err) => { - AsyncClient.dispatchError(err, 'handleLeave'); - } - ); + ChannelActions.leaveChannel(this.state.channel.id); } hideSidebars(e) { |