handle account unlock failure (#594)
* display information to the user upon account_unlock failure * remove trailing dots in messages
This commit is contained in:
parent
4186081fdc
commit
01534caf13
3 changed files with 105 additions and 25 deletions
|
@ -6,6 +6,7 @@ import { decode as atob } from 'base-64';
|
||||||
import { navigateToUri } from 'utils/helper';
|
import { navigateToUri } from 'utils/helper';
|
||||||
import moment from 'moment';
|
import moment from 'moment';
|
||||||
import AsyncStorage from '@react-native-community/async-storage';
|
import AsyncStorage from '@react-native-community/async-storage';
|
||||||
|
import Button from 'component/button';
|
||||||
import ProgressBar from 'component/progressBar';
|
import ProgressBar from 'component/progressBar';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import Colors from 'styles/colors';
|
import Colors from 'styles/colors';
|
||||||
|
@ -14,25 +15,29 @@ import splashStyle from 'styles/splash';
|
||||||
|
|
||||||
const BLOCK_HEIGHT_INTERVAL = 1000 * 60 * 2.5; // every 2.5 minutes
|
const BLOCK_HEIGHT_INTERVAL = 1000 * 60 * 2.5; // every 2.5 minutes
|
||||||
|
|
||||||
|
const testingNetwork = 'Testing network';
|
||||||
|
const waitingForResolution = 'Waiting for name resolution';
|
||||||
|
|
||||||
class SplashScreen extends React.PureComponent {
|
class SplashScreen extends React.PureComponent {
|
||||||
static navigationOptions = {
|
static navigationOptions = {
|
||||||
title: 'Splash',
|
title: 'Splash',
|
||||||
};
|
};
|
||||||
|
|
||||||
componentWillMount() {
|
state = {
|
||||||
this.setState({
|
accountUnlockFailed: false,
|
||||||
daemonReady: false,
|
daemonReady: false,
|
||||||
details: 'Starting up...',
|
details: 'Starting up',
|
||||||
message: 'Connecting',
|
message: 'Connecting',
|
||||||
isRunning: false,
|
isRunning: false,
|
||||||
isLagging: false,
|
isLagging: false,
|
||||||
launchUrl: null,
|
launchUrl: null,
|
||||||
isDownloadingHeaders: false,
|
isDownloadingHeaders: false,
|
||||||
headersDownloadProgress: 0,
|
headersDownloadProgress: 0,
|
||||||
shouldAuthenticate: false,
|
shouldAuthenticate: false,
|
||||||
subscriptionsFetched: false,
|
subscriptionsFetched: false,
|
||||||
});
|
};
|
||||||
|
|
||||||
|
componentWillMount() {
|
||||||
if (NativeModules.DaemonServiceControl) {
|
if (NativeModules.DaemonServiceControl) {
|
||||||
NativeModules.DaemonServiceControl.startService();
|
NativeModules.DaemonServiceControl.startService();
|
||||||
}
|
}
|
||||||
|
@ -143,6 +148,10 @@ class SplashScreen extends React.PureComponent {
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
handleAccountUnlockFailed() {
|
||||||
|
this.setState({ accountUnlockFailed: true });
|
||||||
|
}
|
||||||
|
|
||||||
_updateStatusCallback(status) {
|
_updateStatusCallback(status) {
|
||||||
const { fetchSubscriptions, getSync, setClientSetting } = this.props;
|
const { fetchSubscriptions, getSync, setClientSetting } = this.props;
|
||||||
const startupStatus = status.startup_status;
|
const startupStatus = status.startup_status;
|
||||||
|
@ -155,8 +164,6 @@ class SplashScreen extends React.PureComponent {
|
||||||
// to give us a better sense of when we are actually started
|
// to give us a better sense of when we are actually started
|
||||||
this.setState({
|
this.setState({
|
||||||
daemonReady: true,
|
daemonReady: true,
|
||||||
message: 'Testing Network',
|
|
||||||
details: 'Waiting for name resolution',
|
|
||||||
isLagging: false,
|
isLagging: false,
|
||||||
isRunning: true,
|
isRunning: true,
|
||||||
});
|
});
|
||||||
|
@ -164,14 +171,29 @@ class SplashScreen extends React.PureComponent {
|
||||||
// For now, automatically unlock the wallet if a password is set so that downloads work
|
// For now, automatically unlock the wallet if a password is set so that downloads work
|
||||||
NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(password => {
|
NativeModules.UtilityModule.getSecureValue(Constants.KEY_FIRST_RUN_PASSWORD).then(password => {
|
||||||
if (password && password.trim().length > 0) {
|
if (password && password.trim().length > 0) {
|
||||||
|
this.setState({
|
||||||
|
message: 'Unlocking account',
|
||||||
|
details: 'Decrypting wallet',
|
||||||
|
});
|
||||||
|
|
||||||
// unlock the wallet and then finish the splash screen
|
// unlock the wallet and then finish the splash screen
|
||||||
Lbry.account_unlock({ password })
|
Lbry.account_unlock({ password })
|
||||||
.then(() => this.finishSplashScreen())
|
.then(() => {
|
||||||
.catch(() => this.finishSplashScreen());
|
this.setState({
|
||||||
|
message: testingNetwork,
|
||||||
|
details: waitingForResolution,
|
||||||
|
});
|
||||||
|
this.finishSplashScreen();
|
||||||
|
})
|
||||||
|
.catch(() => this.handleAccountUnlockFailed());
|
||||||
return;
|
return;
|
||||||
|
} else {
|
||||||
|
this.setState({
|
||||||
|
message: testingNetwork,
|
||||||
|
details: waitingForResolution,
|
||||||
|
});
|
||||||
|
this.finishSplashScreen();
|
||||||
}
|
}
|
||||||
|
|
||||||
this.finishSplashScreen();
|
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
|
@ -208,7 +230,7 @@ class SplashScreen extends React.PureComponent {
|
||||||
} else {
|
} else {
|
||||||
this.setState({
|
this.setState({
|
||||||
message: 'Network Loading',
|
message: 'Network Loading',
|
||||||
details: 'Initializing LBRY service...',
|
details: 'Initializing LBRY service',
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,8 +275,41 @@ class SplashScreen extends React.PureComponent {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
handleContinueAnywayPressed = () => {
|
||||||
|
this.setState(
|
||||||
|
{
|
||||||
|
accountUnlockFailed: false,
|
||||||
|
message: testingNetwork,
|
||||||
|
details: waitingForResolution,
|
||||||
|
},
|
||||||
|
() => this.finishSplashScreen()
|
||||||
|
);
|
||||||
|
};
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { message, details, isLagging, isRunning } = this.state;
|
const { accountUnlockFailed, message, details, isLagging, isRunning } = this.state;
|
||||||
|
|
||||||
|
if (accountUnlockFailed) {
|
||||||
|
return (
|
||||||
|
<View style={splashStyle.container}>
|
||||||
|
<Text style={splashStyle.errorTitle}>Oops! Something went wrong.</Text>
|
||||||
|
<Text style={splashStyle.paragraph}>
|
||||||
|
Your wallet failed to unlock, which means you may not be able to play any videos or access your funds.
|
||||||
|
</Text>
|
||||||
|
<Text style={splashStyle.paragraph}>
|
||||||
|
You can try to fix this by tapping Stop on the LBRY service notification and starting the app again. If the
|
||||||
|
problem continues, you may have to reinstall the app and restore your account.
|
||||||
|
</Text>
|
||||||
|
|
||||||
|
<Button
|
||||||
|
style={splashStyle.continueButton}
|
||||||
|
theme={'light'}
|
||||||
|
text={'Continue anyway'}
|
||||||
|
onPress={this.handleContinueAnywayPressed}
|
||||||
|
/>
|
||||||
|
</View>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<View style={splashStyle.container}>
|
<View style={splashStyle.container}>
|
||||||
|
|
|
@ -14,6 +14,31 @@ const splashStyle = StyleSheet.create({
|
||||||
marginBottom: 48,
|
marginBottom: 48,
|
||||||
color: Colors.White,
|
color: Colors.White,
|
||||||
},
|
},
|
||||||
|
errorTitle: {
|
||||||
|
fontFamily: 'Inter-UI-Regular',
|
||||||
|
fontSize: 28,
|
||||||
|
marginBottom: 24,
|
||||||
|
marginLeft: 24,
|
||||||
|
marginRight: 24,
|
||||||
|
color: Colors.White,
|
||||||
|
},
|
||||||
|
paragraph: {
|
||||||
|
fontFamily: 'Inter-UI-Regular',
|
||||||
|
fontSize: 16,
|
||||||
|
lineHeight: 24,
|
||||||
|
marginBottom: 20,
|
||||||
|
marginLeft: 24,
|
||||||
|
marginRight: 24,
|
||||||
|
color: Colors.White,
|
||||||
|
},
|
||||||
|
continueButton: {
|
||||||
|
fontSize: 16,
|
||||||
|
backgroundColor: Colors.White,
|
||||||
|
marginTop: 24,
|
||||||
|
marginLeft: 24,
|
||||||
|
marginRight: 24,
|
||||||
|
alignSelf: 'flex-end',
|
||||||
|
},
|
||||||
loading: {
|
loading: {
|
||||||
marginBottom: 36,
|
marginBottom: 36,
|
||||||
},
|
},
|
||||||
|
|
|
@ -52,24 +52,24 @@ def configure_logging(conf):
|
||||||
conf.log_file_path, maxBytes=2097152, backupCount=5
|
conf.log_file_path, maxBytes=2097152, backupCount=5
|
||||||
)
|
)
|
||||||
file_handler.setFormatter(default_formatter)
|
file_handler.setFormatter(default_formatter)
|
||||||
logging.getLogger('lbrynet').addHandler(file_handler)
|
logging.getLogger('lbry').addHandler(file_handler)
|
||||||
logging.getLogger('torba').addHandler(file_handler)
|
logging.getLogger('torba').addHandler(file_handler)
|
||||||
|
|
||||||
handler = logging.StreamHandler()
|
handler = logging.StreamHandler()
|
||||||
handler.setFormatter(default_formatter)
|
handler.setFormatter(default_formatter)
|
||||||
|
|
||||||
log.addHandler(handler)
|
log.addHandler(handler)
|
||||||
logging.getLogger('lbrynet').addHandler(handler)
|
logging.getLogger('lbry').addHandler(handler)
|
||||||
logging.getLogger('torba').addHandler(handler)
|
logging.getLogger('torba').addHandler(handler)
|
||||||
|
|
||||||
logging.getLogger('aioupnp').setLevel(logging.WARNING)
|
logging.getLogger('aioupnp').setLevel(logging.WARNING)
|
||||||
logging.getLogger('aiohttp').setLevel(logging.CRITICAL)
|
logging.getLogger('aiohttp').setLevel(logging.CRITICAL)
|
||||||
logging.getLogger('lbrynet').setLevel(logging.DEBUG if lbrynet_android_utils.isDebug() else logging.INFO)
|
logging.getLogger('lbry').setLevel(logging.DEBUG if lbrynet_android_utils.isDebug() else logging.INFO)
|
||||||
logging.getLogger('torba').setLevel(logging.INFO)
|
logging.getLogger('torba').setLevel(logging.INFO)
|
||||||
|
|
||||||
loggly_handler = get_loggly_handler()
|
loggly_handler = get_loggly_handler()
|
||||||
loggly_handler.setLevel(logging.ERROR)
|
loggly_handler.setLevel(logging.ERROR)
|
||||||
logging.getLogger('lbrynet').addHandler(loggly_handler)
|
logging.getLogger('lbry').addHandler(loggly_handler)
|
||||||
|
|
||||||
def start():
|
def start():
|
||||||
keyring.set_keyring(LbryAndroidKeyring())
|
keyring.set_keyring(LbryAndroidKeyring())
|
||||||
|
|
Loading…
Reference in a new issue