From cf29d8dec5047bd79e7bfd9f0c697fd4a6a38962 Mon Sep 17 00:00:00 2001 From: Chris Duarte Date: Tue, 14 Nov 2017 03:19:32 -0800 Subject: [PATCH] Use new isFavoriteChannel redux util (#1113) * Use new isFavoriteChannel redux util * Remove unmarkFavorite actions --- app/actions/views/channel.js | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/app/actions/views/channel.js b/app/actions/views/channel.js index f26a8acde..0c7d23a44 100644 --- a/app/actions/views/channel.js +++ b/app/actions/views/channel.js @@ -10,8 +10,7 @@ import { fetchMyChannelsAndMembers, markChannelAsRead, selectChannel, - leaveChannel as serviceLeaveChannel, - unfavoriteChannel + leaveChannel as serviceLeaveChannel } from 'mattermost-redux/actions/channels'; import {getPosts, getPostsBefore, getPostsSince, getPostThread} from 'mattermost-redux/actions/posts'; import {getFilesForPost} from 'mattermost-redux/actions/files'; @@ -20,6 +19,7 @@ import {getTeamMembersByIds} from 'mattermost-redux/actions/teams'; import {getProfilesInChannel} from 'mattermost-redux/actions/users'; import {General, Preferences} from 'mattermost-redux/constants'; import {getCurrentChannelId} from 'mattermost-redux/selectors/entities/channels'; + import { getChannelByName, getDirectChannelName, @@ -379,13 +379,10 @@ export function toggleGMChannel(channelId, visible) { export function closeDMChannel(channel) { return async (dispatch, getState) => { const state = getState(); - - if (channel.isFavorite) { - unfavoriteChannel(channel.id)(dispatch, getState); - } + const currentChannelId = getCurrentChannelId(state); toggleDMChannel(channel.teammate_id, 'false')(dispatch, getState); - if (channel.isCurrent) { + if (channel.id === currentChannelId) { selectInitialChannel(state.entities.teams.currentTeamId)(dispatch, getState); } }; @@ -394,13 +391,10 @@ export function closeDMChannel(channel) { export function closeGMChannel(channel) { return async (dispatch, getState) => { const state = getState(); - - if (channel.isFavorite) { - unfavoriteChannel(channel.id)(dispatch, getState); - } + const currentChannelId = getCurrentChannelId(state); toggleGMChannel(channel.id, 'false')(dispatch, getState); - if (channel.isCurrent) { + if (channel.id === currentChannelId) { selectInitialChannel(state.entities.teams.currentTeamId)(dispatch, getState); } };