traditional mode if dht is enabled

This commit is contained in:
Akinwale Ariwodola 2020-03-19 20:25:31 +01:00
parent 954abf6fdf
commit a7d4e616c7
4 changed files with 39 additions and 54 deletions

@ -1 +1 @@
Subproject commit 6d4d9965137441d4d0d460814b1d89d67f23bc81 Subproject commit 4d98c789cbf19966169b7e561143e8d91bc1a740

View file

@ -447,6 +447,7 @@ class AppWithNavigationState extends React.Component {
}; };
componentWillUnmount() { componentWillUnmount() {
DeviceEventEmitter.removeListener('onSdkReady', this.handleSdkReady);
DeviceEventEmitter.removeListener('onDownloadAborted', this.handleDownloadAborted); DeviceEventEmitter.removeListener('onDownloadAborted', this.handleDownloadAborted);
DeviceEventEmitter.removeListener('onDownloadStarted', this.handleDownloadStarted); DeviceEventEmitter.removeListener('onDownloadStarted', this.handleDownloadStarted);
DeviceEventEmitter.removeListener('onDownloadUpdated', this.handleDownloadUpdated); DeviceEventEmitter.removeListener('onDownloadUpdated', this.handleDownloadUpdated);

View file

@ -55,8 +55,10 @@ import settingsReducer from 'redux/reducers/settings';
import thunk from 'redux-thunk'; import thunk from 'redux-thunk';
window.__ = __; window.__ = __;
Lbry.alternateConnectionString = 'https://api.lbry.tv/api/v1/proxy'; if (!NativeModules.UtilityModule.dhtEnabled) {
Lbry.methodsUsingAlternateConnectionString = ['claim_search', 'resolve']; Lbry.alternateConnectionString = 'https://api.lbry.tv/api/v1/proxy';
Lbry.methodsUsingAlternateConnectionString = ['claim_search', 'resolve'];
}
const globalExceptionHandler = (error, isFatal) => { const globalExceptionHandler = (error, isFatal) => {
if (error && NativeModules.Firebase) { if (error && NativeModules.Firebase) {

View file

@ -85,7 +85,9 @@ class SplashScreen extends React.PureComponent {
const { liteMode } = this.state; const { liteMode } = this.state;
// authenticate immediately // authenticate immediately
this.authenticateWithoutSdk(); if (!NativeModules.UtilityModule.dhtEnabled) {
this.authenticateWithoutSdk();
}
} }
navigateToMain = () => { navigateToMain = () => {
@ -203,15 +205,7 @@ class SplashScreen extends React.PureComponent {
}; };
finishSplashScreen = () => { finishSplashScreen = () => {
const { const { authenticate, getSync, user } = this.props;
authenticate,
balanceSubscribe,
blacklistedOutpointsSubscribe,
filteredOutpointsSubscribe,
getSync,
updateBlockHeight,
user,
} = this.props;
// Leave the splash screen // Leave the splash screen
if (user && user.id && user.has_verified_email) { if (user && user.id && user.has_verified_email) {
@ -233,31 +227,14 @@ class SplashScreen extends React.PureComponent {
}); });
}); });
} }
// });
}; };
handleAccountUnlockFailed() { handleAccountUnlockFailed() {
this.setState({ accountUnlockFailed: true }); this.setState({ accountUnlockFailed: true });
} }
_updateStatusCallback(status) { handleSdkReady = () => {
const { fetchSubscriptions, getSync, setClientSetting } = this.props; this.setState({ daemonReady: true }, () => {
const startupStatus = status.startup_status;
const walletStatus = status.wallet;
// At the minimum, wallet should be started and blocks_behind equal to 0 before calling resolve
const hasStarted = startupStatus.stream_manager && startupStatus.wallet && status.wallet.blocks_behind <= 0;
if (hasStarted) {
// Wait until we are able to resolve a name before declaring
// that we are done.
// TODO: This is a hack, and the logic should live in the daemon
// to give us a better sense of when we are actually started
this.setState({
daemonReady: true,
isLagging: false,
isRunning: true,
});
Lbry.wallet_status().then(secureWalletStatus => { Lbry.wallet_status().then(secureWalletStatus => {
// 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_WALLET_PASSWORD).then(password => { NativeModules.UtilityModule.getSecureValue(Constants.KEY_WALLET_PASSWORD).then(password => {
@ -288,9 +265,12 @@ class SplashScreen extends React.PureComponent {
} }
}); });
}); });
});
};
return; handleSdkStatusResponse = evt => {
} const { status } = evt;
const walletStatus = status.wallet;
const headerSyncProgress = walletStatus ? walletStatus.headers_synchronization_progress : null; const headerSyncProgress = walletStatus ? walletStatus.headers_synchronization_progress : null;
if (headerSyncProgress && headerSyncProgress < 100) { if (headerSyncProgress && headerSyncProgress < 100) {
@ -325,23 +305,24 @@ class SplashScreen extends React.PureComponent {
details: __('Initializing LBRY service'), details: __('Initializing LBRY service'),
}); });
} }
};
setTimeout(() => {
this.updateStatus();
}, 1000);
}
componentWillMount() { componentWillMount() {
DeviceEventEmitter.addListener('onNotificationTargetLaunch', this.onNotificationTargetLaunch); DeviceEventEmitter.addListener('onNotificationTargetLaunch', this.onNotificationTargetLaunch);
DeviceEventEmitter.addListener('onSdkReady', this.handleSdkReady);
DeviceEventEmitter.addListener('onSdkStatusResponse', this.handleSdkStatusResponse);
} }
componentWillUnmount() { componentWillUnmount() {
DeviceEventEmitter.removeListener('onNotificationTargetLaunch', this.onNotificationTargetLaunch); DeviceEventEmitter.removeListener('onNotificationTargetLaunch', this.onNotificationTargetLaunch);
DeviceEventEmitter.removeListener('onSdkReady', this.handleSdkReady);
DeviceEventEmitter.removeListener('onSdkStatusResponse', this.handleSdkStatusResponse);
} }
componentDidMount() { componentDidMount() {
NativeModules.Firebase.track('app_launch', null); NativeModules.Firebase.track('app_launch', null);
NativeModules.Firebase.setCurrentScreen('Splash'); NativeModules.Firebase.setCurrentScreen('Splash');
const { navigation } = this.props; const { navigation } = this.props;
const { resetUrl } = navigation.state.params; const { resetUrl } = navigation.state.params;
const isResetUrlSet = !!resetUrl; const isResetUrlSet = !!resetUrl;
@ -377,22 +358,23 @@ class SplashScreen extends React.PureComponent {
} }
lbryConnect = () => { lbryConnect = () => {
this.updateStatus(); // skip lbry.connect for now (unless dht flag is enabled) if (NativeModules.UtilityModule.dhtEnabled) {
/* Lbry.connect()
Lbry.connect() .then(() => {
.then(() => { this.updateStatus();
this.updateStatus(); })
}) .catch(e => {
.catch(e => { this.setState({
this.setState({ isLagging: true,
isLagging: true, message: __('Connection Failure'),
message: __('Connection Failure'), details: __(
details: __( 'We could not establish a connection to the SDK. Your data connection may be preventing LBRY from connecting. Contact hello@lbry.com if you think this is a software bug.',
'We could not establish a connection to the SDK. Your data connection may be preventing LBRY from connecting. Contact hello@lbry.com if you think this is a software bug.', ),
), });
}); });
}); } else {
*/ this.updateStatus(); // skip lbry.connect for now (unless dht flag is enabled)
}
}; };
handleContinueAnywayPressed = () => { handleContinueAnywayPressed = () => {