diff --git a/components/ProgressBar.qml b/components/ProgressBar.qml index 33f2c585..ec53ec61 100644 --- a/components/ProgressBar.qml +++ b/components/ProgressBar.qml @@ -42,7 +42,7 @@ Item { var progressLevel = ((currentBlock/targetBlock) * 100).toFixed(0); fillLevel = progressLevel progressText.text = qsTr("Synchronizing blocks %1/%2").arg(currentBlock.toFixed(0)).arg(targetBlock.toFixed(0)); - item.visible = (currentWallet.connected !== Wallet.ConnectionStatus_Disconnected) && (currentBlock < targetBlock) + progressBar.visible = currentBlock < targetBlock } } diff --git a/main.qml b/main.qml index e0f48142..4296fe26 100644 --- a/main.qml +++ b/main.qml @@ -54,7 +54,6 @@ ApplicationWindow { property var transaction; property var transactionDescription; property alias password : passwordDialog.password - property int splashCounter: 0 property bool isNewWallet: false property int restoreHeight:0 property bool daemonSynced: false @@ -261,10 +260,12 @@ ApplicationWindow { return path.replace(/.*[\/\\]/, '').replace(/\.keys$/, '') } - function onWalletConnectionStatusChanged(){ + function onWalletConnectionStatusChanged(status){ console.log("Wallet connection status changed") middlePanel.updateStatus(); - } + leftPanel.networkStatus.connected = status + leftPanel.progressBar.visible = (status === Wallet.ConnectionStatus_Connected) && !daemonSynced + } function onWalletOpened(wallet) { walletName = usefulName(wallet.path) @@ -306,7 +307,6 @@ ApplicationWindow { console.log(">>> wallet updated") middlePanel.unlockedBalanceText = leftPanel.unlockedBalanceText = walletManager.displayAmount(currentWallet.unlockedBalance); middlePanel.balanceText = leftPanel.balanceText = walletManager.displayAmount(currentWallet.balance); - console.log("time to unlock: ", currentWallet.history.minutesToUnlock); // Update history if new block found since last update and balance is locked. if(foundNewBlock && currentWallet.history.locked) { foundNewBlock = false; @@ -332,11 +332,16 @@ ApplicationWindow { // Daemon fully synced // TODO: implement onDaemonSynced or similar in wallet API and don't start refresh thread before daemon is synced - daemonSynced = (currentWallet.connected != Wallet.ConnectionStatus_Disconnected && dCurrentBlock >= dTargetBlock) + daemonSynced = dCurrentBlock >= dTargetBlock + // Update daemon sync progress leftPanel.progressBar.updateProgress(dCurrentBlock,dTargetBlock); - updateSyncing((currentWallet.connected !== Wallet.ConnectionStatus_Disconnected) && (dCurrentBlock < dTargetBlock)) + leftPanel.progressBar.visible = !daemonSynced && currentWallet.connected !== Wallet.ConnectionStatus_Disconnected + // Update wallet sync progress + updateSyncing((currentWallet.connected !== Wallet.ConnectionStatus_Disconnected) && !daemonSynced) + // Update transfer page status middlePanel.updateStatus(); + // If wallet isnt connected and no daemon is running - Ask if(currentWallet.connected === Wallet.ConnectionStatus_Disconnected && !daemonManager.running() && !walletInitialized){ daemonManagerDialog.open(); @@ -388,17 +393,10 @@ ApplicationWindow { daemonRunning = false; } - function onWalletNewBlock(blockHeight) { - // Update progress bar - var currHeight = blockHeight - //fast refresh until restoreHeight is reached - var increment = ((restoreHeight == 0) || currHeight < restoreHeight)? 1000 : 10 - - if(currHeight > splashCounter + increment){ - splashCounter = currHeight - leftPanel.progressBar.updateProgress(currHeight,currentWallet.daemonBlockChainTargetHeight()); - } - foundNewBlock = true; + function onWalletNewBlock(blockHeight, targetHeight) { + // Update progress bar + leftPanel.progressBar.updateProgress(blockHeight,targetHeight); + foundNewBlock = true; } function onWalletMoneyReceived(txId, amount) { @@ -708,7 +706,6 @@ ApplicationWindow { // close wallet and show wizard function showWizard(){ walletInitialized = false; - splashCounter = 0; closeWallet(); currentWallet = undefined; wizard.restart(); diff --git a/pages/Transfer.qml b/pages/Transfer.qml index 74e5d114..05e78c12 100644 --- a/pages/Transfer.qml +++ b/pages/Transfer.qml @@ -655,7 +655,6 @@ Rectangle { //TODO: enable send page when we're connected and daemon is synced function updateStatus() { - console.log("updated transfer page status") if(typeof currentWallet === "undefined") { statusText.text = qsTr("Wallet is not connected to daemon.") + "
" + root.startLinkText return; diff --git a/src/libwalletqt/Wallet.cpp b/src/libwalletqt/Wallet.cpp index 0e4e09a3..56121370 100644 --- a/src/libwalletqt/Wallet.cpp +++ b/src/libwalletqt/Wallet.cpp @@ -127,9 +127,9 @@ void Wallet::updateConnectionStatusAsync() Wallet::ConnectionStatus Wallet::connected(bool forceCheck) { - qDebug() << "Checking connection status"; // cache connection status if (forceCheck || !m_initialized || (m_connectionStatusTime.elapsed() / 1000 > m_connectionStatusTtl && !m_connectionStatusRunning) || m_connectionStatusTime.elapsed() > 30000) { + qDebug() << "Checking connection status"; m_connectionStatusRunning = true; m_initialized = true; m_connectionStatusTime.restart();