Fixed error being thrown by ChannelHeader when switching teams (#4619)

* Fixed error being thrown by ChannelHeader when switching teams

* Close SidebarHeaderDropdown after switching teams
Этот коммит содержится в:
Harrison Healey
2016-11-21 16:08:29 -05:00
коммит произвёл GitHub
родитель 43c703e216
Коммит 3c0f8c29db
2 изменённых файлов: 8 добавлений и 1 удалений

Просмотреть файл

@@ -69,7 +69,7 @@ export default class ChannelHeader extends React.Component {
const users = UserStore.getProfileListInChannel(this.props.channelId);
let otherUserId = null;
if (channel.type === 'D') {
if (channel && channel.type === 'D') {
otherUserId = Utils.getUserIdFromChannelName(channel);
}

Просмотреть файл

@@ -45,6 +45,7 @@ export default class SidebarHeaderDropdown extends React.Component {
this.showGetTeamInviteLinkModal = this.showGetTeamInviteLinkModal.bind(this);
this.showTeamMembersModal = this.showTeamMembersModal.bind(this);
this.hideTeamMembersModal = this.hideTeamMembersModal.bind(this);
this.handleSwitchTeams = this.handleSwitchTeams.bind(this);
this.onTeamChange = this.onTeamChange.bind(this);
this.openAccountSettings = this.openAccountSettings.bind(this);
@@ -131,6 +132,11 @@ export default class SidebarHeaderDropdown extends React.Component {
});
}
handleSwitchTeams() {
// The actual switching of teams is handled by the react-router Link
this.setState({showDropdown: false});
}
componentDidMount() {
TeamStore.addChangeListener(this.onTeamChange);
document.addEventListener('keydown', this.openAccountSettings);
@@ -367,6 +373,7 @@ export default class SidebarHeaderDropdown extends React.Component {
<li key={'team_' + team.name}>
<Link
to={'/' + team.name + '/channels/town-square'}
onClick={this.handleSwitchTeams}
>
<FormattedMessage
id='navbar_dropdown.switchTo'