This commit is contained in:
u-e 2018-12-18 15:11:18 +03:00
parent 4f2d8b9f5f
commit fdb9f8b035
2 changed files with 8 additions and 3 deletions

View File

@ -73,6 +73,7 @@ export const Login = (username, password) => {
setUserData(userData)
.then(() => {
resolve({ ...account, password });
updateCurrentUsername(account.name);
})
.catch(() => {
reject(new Error('Invalid credentails, please check and try again'));
@ -127,6 +128,7 @@ export const loginWithSC2 = async (accessToken) => {
.then(() => {
account.account.username = account.account.name;
resolve({ ...account.account, accessToken });
updateCurrentUsername(account.account.name);
})
.catch((error) => {
reject(error);

View File

@ -56,13 +56,14 @@ class ApplicationContainer extends Component {
super();
this.state = {
isRenderRequire: true,
isReady: false,
};
}
componentDidMount = async () => {
BackHandler.addEventListener('hardwareBackPress', this._onBackPress);
await this._getUserData();
this._getSettings();
await this._getSettings();
};
componentWillReceiveProps(nextProps) {
@ -146,6 +147,8 @@ class ApplicationContainer extends Component {
response.notification && dispatch(isNotificationOpen(response.notification));
response.server && dispatch(setApi(response.server));
response.upvotePercent && dispatch(setUpvotePercent(Number(response.upvotePercent)));
this.setState({isReady: true});
}
});
};
@ -226,14 +229,14 @@ class ApplicationContainer extends Component {
render() {
const { selectedLanguage } = this.props;
const { isRenderRequire } = this.state;
const { isRenderRequire, isReady } = this.state;
const locale = (navigator.languages && navigator.languages[0])
|| navigator.language
|| navigator.userLanguage
|| selectedLanguage;
if (isRenderRequire) {
if (isRenderRequire && isReady) {
return <ApplicationScreen locale={locale} {...this.props} />;
}
return null;