[MM-36998] Ensure server key must be at least 0 (#1660)

This commit is contained in:
Devin Binnie
2021-07-19 11:29:38 -04:00
committed by GitHub
parent ccd515e50c
commit 29a049e8ae

View File

@@ -103,7 +103,7 @@ export default class MainPage extends React.PureComponent<Props, State> {
this.threeDotMenu = React.createRef();
this.state = {
key: this.props.teams.findIndex((team) => team.order === 0),
key: this.props.teams.length ? this.props.teams.findIndex((team) => team.order === 0) : 0,
sessionsExpired: {},
unreadCounts: {},
mentionCounts: {},
@@ -259,7 +259,7 @@ export default class MainPage extends React.PureComponent<Props, State> {
}
handleSetServerKey = (key: number) => {
const newKey = (this.props.teams.length + key) % this.props.teams.length;
const newKey = ((this.props.teams.length + key) % this.props.teams.length) || 0;
this.setState({key: newKey});
}
@@ -322,6 +322,10 @@ export default class MainPage extends React.PureComponent<Props, State> {
}
render() {
if (!this.props.teams.length) {
return null;
}
const tabsRow = (
<TabBar
id='tabBar'