From 9485d4e88dd2ada9a4541b602d53c27bafb17a7b Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Tue, 5 Mar 2019 11:56:24 -0300 Subject: [PATCH] Set the correct channel display name when switching teams (#2625) --- app/actions/views/channel.js | 6 +++--- app/components/sidebars/main/main_sidebar.js | 10 +--------- 2 files changed, 4 insertions(+), 12 deletions(-) diff --git a/app/actions/views/channel.js b/app/actions/views/channel.js index 03c4b07a1..d19c9f91b 100644 --- a/app/actions/views/channel.js +++ b/app/actions/views/channel.js @@ -18,7 +18,7 @@ import {savePreferences} from 'mattermost-redux/actions/preferences'; import {getTeamMembersByIds} from 'mattermost-redux/actions/teams'; import {getProfilesInChannel} from 'mattermost-redux/actions/users'; import {General, Preferences} from 'mattermost-redux/constants'; -import {getCurrentChannelId, getMyChannelMember} from 'mattermost-redux/selectors/entities/channels'; +import {getChannel, getCurrentChannelId, getMyChannelMember} from 'mattermost-redux/selectors/entities/channels'; import {getCurrentTeamId, getTeamByName} from 'mattermost-redux/selectors/entities/teams'; import { @@ -313,7 +313,6 @@ export function selectPenultimateChannel(teamId) { (lastChannel.team_id === teamId || isDMVisible || isGMVisible) ) { dispatch(setChannelLoading(true)); - dispatch(setChannelDisplayName(lastChannel.display_name)); dispatch(handleSelectChannel(lastChannelId)); return; } @@ -340,7 +339,6 @@ export function selectDefaultChannel(teamId) { } if (channelId) { - dispatch(setChannelDisplayName('')); dispatch(handleSelectChannel(channelId)); } }; @@ -349,6 +347,7 @@ export function selectDefaultChannel(teamId) { export function handleSelectChannel(channelId) { return async (dispatch, getState) => { const state = getState(); + const channel = getChannel(state, channelId); const currentTeamId = getCurrentTeamId(state); const currentChannelId = getCurrentChannelId(state); const sameChannel = channelId === currentChannelId; @@ -358,6 +357,7 @@ export function handleSelectChannel(channelId) { dispatch(loadPostsIfNecessaryWithRetry(channelId)); dispatch(batchActions([ selectChannel(channelId), + setChannelDisplayName(channel.display_name), { type: ViewTypes.SET_INITIAL_POST_VISIBILITY, data: channelId, diff --git a/app/components/sidebars/main/main_sidebar.js b/app/components/sidebars/main/main_sidebar.js index 1b28ba2e1..b837a04a7 100644 --- a/app/components/sidebars/main/main_sidebar.js +++ b/app/components/sidebars/main/main_sidebar.js @@ -164,14 +164,7 @@ export default class ChannelSidebar extends Component { }; selectChannel = (channel, currentChannelId, closeDrawer = true) => { - const { - actions, - } = this.props; - - const { - setChannelLoading, - setChannelDisplayName, - } = actions; + const {setChannelLoading} = this.props.actions; tracker.channelSwitch = Date.now(); @@ -195,7 +188,6 @@ export default class ChannelSidebar extends Component { return; } - setChannelDisplayName(channel.display_name); EventEmitter.emit('switch_channel', channel, currentChannelId); };