mirror of
https://github.com/LBRYFoundation/lbry-desktop.git
synced 2025-08-27 15:31:27 +00:00
Sync status and SDK upgrade
Check is_syncing while loading the app so we don't try to refresh the wallet / show error message.
This commit is contained in:
parent
25bf9290e1
commit
dab354cfd7
3 changed files with 54 additions and 31 deletions
|
@ -130,7 +130,7 @@
|
||||||
"imagesloaded": "^4.1.4",
|
"imagesloaded": "^4.1.4",
|
||||||
"json-loader": "^0.5.4",
|
"json-loader": "^0.5.4",
|
||||||
"lbry-format": "https://github.com/lbryio/lbry-format.git",
|
"lbry-format": "https://github.com/lbryio/lbry-format.git",
|
||||||
"lbry-redux": "lbryio/lbry-redux#b7ae238606587696f92718120a646a5965ee8ae9",
|
"lbry-redux": "lbryio/lbry-redux#625a624b9c2d5839e25c1a592d69b9f312944fe0",
|
||||||
"lbryinc": "lbryio/lbryinc#19260fac560daaa4be2d4af372f28109ea96ebf9",
|
"lbryinc": "lbryio/lbryinc#19260fac560daaa4be2d4af372f28109ea96ebf9",
|
||||||
"lint-staged": "^7.0.2",
|
"lint-staged": "^7.0.2",
|
||||||
"localforage": "^1.7.1",
|
"localforage": "^1.7.1",
|
||||||
|
@ -209,7 +209,7 @@
|
||||||
"yarn": "^1.3"
|
"yarn": "^1.3"
|
||||||
},
|
},
|
||||||
"lbrySettings": {
|
"lbrySettings": {
|
||||||
"lbrynetDaemonVersion": "0.67.0",
|
"lbrynetDaemonVersion": "0.66.0",
|
||||||
"lbrynetDaemonUrlTemplate": "https://github.com/lbryio/lbry/releases/download/vDAEMONVER/lbrynet-OSNAME.zip",
|
"lbrynetDaemonUrlTemplate": "https://github.com/lbryio/lbry/releases/download/vDAEMONVER/lbrynet-OSNAME.zip",
|
||||||
"lbrynetDaemonDir": "static/daemon",
|
"lbrynetDaemonDir": "static/daemon",
|
||||||
"lbrynetDaemonFileName": "lbrynet"
|
"lbrynetDaemonFileName": "lbrynet"
|
||||||
|
|
|
@ -13,8 +13,9 @@ import I18nMessage from 'component/i18nMessage';
|
||||||
import 'css-doodle';
|
import 'css-doodle';
|
||||||
|
|
||||||
const FORTY_FIVE_SECONDS = 45 * 1000;
|
const FORTY_FIVE_SECONDS = 45 * 1000;
|
||||||
const UPDATE_INTERVAL = 500; // .5 seconds
|
const UPDATE_INTERVAL = 1000; // 1 second
|
||||||
const MAX_WALLET_WAIT = 20; // 10 seconds for wallet to be started, but servers to be unavailable
|
const MAX_WALLET_WAIT = 20; // 20 seconds for wallet to be started, but servers to be unavailable
|
||||||
|
const MAX_SYNC_WAIT = 45; // 45 seconds to sync wallet, show message if taking long
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
checkDaemonVersion: () => Promise<any>,
|
checkDaemonVersion: () => Promise<any>,
|
||||||
|
@ -39,6 +40,7 @@ type State = {
|
||||||
isRunning: boolean,
|
isRunning: boolean,
|
||||||
launchWithIncompatibleDaemon: boolean,
|
launchWithIncompatibleDaemon: boolean,
|
||||||
waitingForWallet: number,
|
waitingForWallet: number,
|
||||||
|
waitingForSync: number,
|
||||||
};
|
};
|
||||||
|
|
||||||
export default class SplashScreen extends React.PureComponent<Props, State> {
|
export default class SplashScreen extends React.PureComponent<Props, State> {
|
||||||
|
@ -53,6 +55,7 @@ export default class SplashScreen extends React.PureComponent<Props, State> {
|
||||||
launchWithIncompatibleDaemon: !process.env.NODE_ENV === 'production',
|
launchWithIncompatibleDaemon: !process.env.NODE_ENV === 'production',
|
||||||
isRunning: false,
|
isRunning: false,
|
||||||
waitingForWallet: 0,
|
waitingForWallet: 0,
|
||||||
|
waitingForSync: 0,
|
||||||
};
|
};
|
||||||
|
|
||||||
(this: any).renderModals = this.renderModals.bind(this);
|
(this: any).renderModals = this.renderModals.bind(this);
|
||||||
|
@ -106,39 +109,46 @@ export default class SplashScreen extends React.PureComponent<Props, State> {
|
||||||
const { launchedModal } = this.state;
|
const { launchedModal } = this.state;
|
||||||
|
|
||||||
Lbry.status().then(status => {
|
Lbry.status().then(status => {
|
||||||
|
const sdkStatus = status;
|
||||||
const { wallet } = status;
|
const { wallet } = status;
|
||||||
if (status.is_running && wallet && wallet.available_servers) {
|
Lbry.wallet_status().then(status => {
|
||||||
Lbry.wallet_status().then(walletStatus => {
|
if (sdkStatus.is_running && wallet && wallet.available_servers) {
|
||||||
if (walletStatus.is_locked) {
|
if (status.is_locked) {
|
||||||
// Clear the error timeout, it might sit on this step for a while until someone enters their password
|
// Clear the error timeout, it might sit on this step for a while until someone enters their password
|
||||||
if (this.timeout) {
|
if (this.timeout) {
|
||||||
clearTimeout(this.timeout);
|
clearTimeout(this.timeout);
|
||||||
}
|
}
|
||||||
// Make sure there isn't another active modal (like INCOMPATIBLE_DAEMON)
|
// Make sure there isn't another active modal (like INCOMPATIBLE_DAEMON)
|
||||||
this.updateStatusCallback(status, true);
|
this.updateStatusCallback(sdkStatus, status, true);
|
||||||
if (launchedModal === false && !modal) {
|
if (launchedModal === false && !modal) {
|
||||||
this.setState({ launchedModal: true }, () => notifyUnlockWallet());
|
this.setState({ launchedModal: true }, () => notifyUnlockWallet());
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.updateStatusCallback(status);
|
this.updateStatusCallback(sdkStatus, status);
|
||||||
}
|
}
|
||||||
});
|
} else if (!sdkStatus.is_running && status.is_syncing) {
|
||||||
} else if (this.state.waitingForWallet > MAX_WALLET_WAIT && launchedModal === false && !modal) {
|
// Clear the timeout if wallet is still syncing
|
||||||
clearWalletServers();
|
if (this.timeout) {
|
||||||
doShowSnackBar(
|
clearTimeout(this.timeout);
|
||||||
__(
|
}
|
||||||
'The wallet server took a bit too long. Resetting defaults just in case. Shutdown (Cmd/Ctrl+Q) LBRY and restart if this continues.'
|
this.updateStatusCallback(sdkStatus, status);
|
||||||
)
|
} else if (this.state.waitingForWallet > MAX_WALLET_WAIT && launchedModal === false && !modal) {
|
||||||
);
|
clearWalletServers();
|
||||||
this.setState({ waitingForWallet: 0 });
|
doShowSnackBar(
|
||||||
this.updateStatusCallback(status);
|
__(
|
||||||
} else {
|
'The wallet server took a bit too long. Resetting defaults just in case. Shutdown (Cmd/Ctrl+Q) LBRY and restart if this continues.'
|
||||||
this.updateStatusCallback(status);
|
)
|
||||||
}
|
);
|
||||||
|
this.setState({ waitingForWallet: 0 });
|
||||||
|
this.updateStatusCallback(sdkStatus, status);
|
||||||
|
} else {
|
||||||
|
this.updateStatusCallback(sdkStatus, status);
|
||||||
|
}
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
updateStatusCallback(status: StatusResponse, waitingForUnlock: boolean = false) {
|
updateStatusCallback(status: StatusResponse, walletStatus: WalletStatusResponse, waitingForUnlock: boolean = false) {
|
||||||
if (status.connection_status.code !== 'connected') {
|
if (status.connection_status.code !== 'connected') {
|
||||||
this.setState({ error: true });
|
this.setState({ error: true });
|
||||||
return;
|
return;
|
||||||
|
@ -155,12 +165,25 @@ export default class SplashScreen extends React.PureComponent<Props, State> {
|
||||||
});
|
});
|
||||||
|
|
||||||
return;
|
return;
|
||||||
} else if (wallet && wallet.blocks_behind > 0) {
|
} else if (wallet && !status.is_running && walletStatus.is_syncing) {
|
||||||
this.setState({
|
this.setState({ waitingForSync: this.state.waitingForSync + UPDATE_INTERVAL / 1000 });
|
||||||
message: __('Blockchain Sync'),
|
if (this.state.waitingForSync < MAX_SYNC_WAIT) {
|
||||||
details: `${__('Catching up...')} (${wallet.headers_synchronization_progress}%)`,
|
this.setState({
|
||||||
});
|
message: 'Loading Wallet',
|
||||||
} else if (wallet && wallet.blocks_behind === 0 && !status.is_running && startupStatus.database) {
|
details: 'Updating wallet data...',
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.setState({
|
||||||
|
message: 'Loading Wallet',
|
||||||
|
details: (
|
||||||
|
<React.Fragment>
|
||||||
|
<div>Large account history</div>
|
||||||
|
<div>Please wait...</div>
|
||||||
|
</React.Fragment>
|
||||||
|
),
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else if (wallet && !status.is_running && startupStatus.database) {
|
||||||
this.setState({
|
this.setState({
|
||||||
message: 'Finalizing',
|
message: 'Finalizing',
|
||||||
details: 'Almost ready...',
|
details: 'Almost ready...',
|
||||||
|
|
|
@ -6138,9 +6138,9 @@ lazy-val@^1.0.4:
|
||||||
yargs "^13.2.2"
|
yargs "^13.2.2"
|
||||||
zstd-codec "^0.1.1"
|
zstd-codec "^0.1.1"
|
||||||
|
|
||||||
lbry-redux@lbryio/lbry-redux#b7ae238606587696f92718120a646a5965ee8ae9:
|
lbry-redux@lbryio/lbry-redux#625a624b9c2d5839e25c1a592d69b9f312944fe0:
|
||||||
version "0.0.1"
|
version "0.0.1"
|
||||||
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/b7ae238606587696f92718120a646a5965ee8ae9"
|
resolved "https://codeload.github.com/lbryio/lbry-redux/tar.gz/625a624b9c2d5839e25c1a592d69b9f312944fe0"
|
||||||
dependencies:
|
dependencies:
|
||||||
proxy-polyfill "0.1.6"
|
proxy-polyfill "0.1.6"
|
||||||
reselect "^3.0.0"
|
reselect "^3.0.0"
|
||||||
|
|
Loading…
Add table
Reference in a new issue