diff options
Diffstat (limited to 'webapp/actions/channel_actions.jsx')
-rw-r--r-- | webapp/actions/channel_actions.jsx | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/webapp/actions/channel_actions.jsx b/webapp/actions/channel_actions.jsx index c9c04d462..340f90fc4 100644 --- a/webapp/actions/channel_actions.jsx +++ b/webapp/actions/channel_actions.jsx @@ -6,6 +6,7 @@ import AppDispatcher from 'dispatcher/app_dispatcher.jsx'; import TeamStore from 'stores/team_store.jsx'; import UserStore from 'stores/user_store.jsx'; import ChannelStore from 'stores/channel_store.jsx'; +import * as ChannelUtils from 'utils/channel_utils.jsx'; import PreferenceStore from 'stores/preference_store.jsx'; import {loadProfilesAndTeamMembersForDMSidebar} from 'actions/user_actions.jsx'; @@ -434,3 +435,29 @@ export function getChannelMembersForUserIds(channelId, userIds, success, error) } ); } + +export function leaveChannel(channelId, success, error) { + Client.leaveChannel(channelId, + () => { + loadChannelsForCurrentUser(); + + if (ChannelUtils.isFavoriteChannelId(channelId)) { + unmarkFavorite(channelId); + } + + const townsquare = ChannelStore.getByName('town-square'); + browserHistory.push(TeamStore.getCurrentTeamRelativeUrl() + '/channels/' + townsquare.name); + + if (success) { + success(); + } + }, + (err) => { + AsyncClient.dispatchError(err, 'handleLeave'); + + if (error) { + error(err); + } + } + ); +} |