From 8a513ecd0c791ebf54844ffb72a20923f023eb0f Mon Sep 17 00:00:00 2001 From: Mustafa Buyukcelebi Date: Wed, 17 Jul 2019 13:09:58 +0300 Subject: [PATCH] Login screen fixed for offline mode --- src/config/locales/en-US.json | 4 +++- src/screens/login/container/loginContainer.js | 23 ++++++++++++++++--- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/src/config/locales/en-US.json b/src/config/locales/en-US.json index fdf18ce18..1910dc82e 100644 --- a/src/config/locales/en-US.json +++ b/src/config/locales/en-US.json @@ -203,7 +203,9 @@ "no_internet": "No connection!", "confirm": "Confirm", "removed": "Removed", - "same_user": "This user already added to list" + "same_user": "This user already added to list", + "unknow_error": "An error occurred", + "error": "Error" }, "post": { "reblog_alert": "Are you sure you want to reblog?", diff --git a/src/screens/login/container/loginContainer.js b/src/screens/login/container/loginContainer.js index ff4d5f6c5..9bc557b19 100644 --- a/src/screens/login/container/loginContainer.js +++ b/src/screens/login/container/loginContainer.js @@ -108,13 +108,29 @@ class LoginContainer extends PureComponent { }; _getAccountsWithUsername = async username => { - const validUsers = await lookupAccounts(username); - return validUsers; + const { intl, isConnected } = this.props; + + if (isConnected) { + return null; + } + + try { + const validUsers = await lookupAccounts(username); + + return validUsers; + } catch (error) { + Alert.alert( + intl.formatMessage({ id: 'alert.error' }), + intl.formatMessage({ d: 'alert.unknow_error' }), + ); + } }; _handleSignUp = () => { + const { intl } = this.props; + Linking.openURL('https://signup.steemit.com/?ref=esteem').catch(err => - alert('An error occurred', err), + Alert.alert(intl.formatMessage({ id: 'alert.error' }), err.message), ); }; @@ -137,6 +153,7 @@ const mapStateToProps = state => ({ account: state.accounts, notificationDetails: state.application.notificationDetails, notificationSettings: state.application.isNotificationOpen, + isConnected: state.application.isConnected, }); export default injectIntl(connect(mapStateToProps)(LoginContainer));