[MM-36998] Ensure server key must be at least 0 (#1660)
This commit is contained in:
@@ -103,7 +103,7 @@ export default class MainPage extends React.PureComponent<Props, State> {
|
|||||||
this.threeDotMenu = React.createRef();
|
this.threeDotMenu = React.createRef();
|
||||||
|
|
||||||
this.state = {
|
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: {},
|
sessionsExpired: {},
|
||||||
unreadCounts: {},
|
unreadCounts: {},
|
||||||
mentionCounts: {},
|
mentionCounts: {},
|
||||||
@@ -259,7 +259,7 @@ export default class MainPage extends React.PureComponent<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
handleSetServerKey = (key: number) => {
|
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});
|
this.setState({key: newKey});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -322,6 +322,10 @@ export default class MainPage extends React.PureComponent<Props, State> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
|
if (!this.props.teams.length) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
const tabsRow = (
|
const tabsRow = (
|
||||||
<TabBar
|
<TabBar
|
||||||
id='tabBar'
|
id='tabBar'
|
||||||
|
Reference in New Issue
Block a user