Set the correct channel display name when switching teams (#2625)

This commit is contained in:
Elias Nahum 2019-03-05 11:56:24 -03:00
parent 2c5252e386
commit 9485d4e88d
No known key found for this signature in database
GPG key ID: E038DB71E0B61702
2 changed files with 4 additions and 12 deletions

View file

@ -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,

View file

@ -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);
};