Skip await for loadMe if we have the currentUser (#1055)
This commit is contained in:
parent
b2b2b24051
commit
53f0576672
2 changed files with 10 additions and 3 deletions
|
|
@ -5,13 +5,14 @@ import {bindActionCreators} from 'redux';
|
|||
import {connect} from 'react-redux';
|
||||
|
||||
import {loadMe} from 'mattermost-redux/actions/users';
|
||||
|
||||
import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';
|
||||
import {getTheme} from 'mattermost-redux/selectors/entities/preferences';
|
||||
|
||||
import Root from './root';
|
||||
|
||||
function mapStateToProps(state) {
|
||||
return {
|
||||
currentUser: getCurrentUser(state),
|
||||
credentials: state.entities.general.credentials,
|
||||
theme: getTheme(state)
|
||||
};
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ import {stripTrailingSlashes} from 'app/utils/url';
|
|||
export default class Root extends Component {
|
||||
static propTypes = {
|
||||
allowOtherServers: PropTypes.bool,
|
||||
currentUser: PropTypes.object,
|
||||
credentials: PropTypes.object,
|
||||
justInit: PropTypes.bool,
|
||||
navigator: PropTypes.object,
|
||||
|
|
@ -73,7 +74,7 @@ export default class Root extends Component {
|
|||
};
|
||||
|
||||
loadStoreAndScene = () => {
|
||||
const {actions, credentials} = this.props;
|
||||
const {actions, currentUser, credentials} = this.props;
|
||||
const {loadMe} = actions;
|
||||
if (credentials.token && credentials.url) {
|
||||
Client.setToken(credentials.token);
|
||||
|
|
@ -81,7 +82,12 @@ export default class Root extends Component {
|
|||
Client4.setUrl(stripTrailingSlashes(credentials.url));
|
||||
Client.setUrl(stripTrailingSlashes(credentials.url));
|
||||
|
||||
loadMe().then(this.goToLoadTeam).catch(this.goToLoadTeam);
|
||||
if (currentUser) {
|
||||
loadMe();
|
||||
this.goToLoadTeam();
|
||||
} else {
|
||||
loadMe().then(this.goToLoadTeam).catch(this.goToLoadTeam);
|
||||
}
|
||||
} else {
|
||||
this.goToSelectServer();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue