]> Nutra Git (v1) - gamesguru/feather.git/commitdiff
wip better network update tooltip; TODO prune lastConfigSave junk
authorgg <chown_tee@proton.me>
Sun, 18 Jan 2026 19:29:52 +0000 (14:29 -0500)
committergg <chown_tee@proton.me>
Sun, 18 Jan 2026 19:30:36 +0000 (14:30 -0500)
src/MainWindow.cpp
src/utils/WebsocketClient.cpp
src/utils/config.cpp
src/utils/config.h

index 8d40e60d57bd55404a507a7b56abb234ba7d148f..5f0dc0a7b6e9e78d4da4bf36813357719a5fc764 100644 (file)
@@ -431,8 +431,15 @@ void MainWindow::initWidgets() {
     connect(m_walletUnlockWidget, &WalletUnlockWidget::closeWallet, this, &MainWindow::close);
     connect(m_walletUnlockWidget, &WalletUnlockWidget::unlockWallet, this, &MainWindow::unlockWallet);
 
+    ui->tabWidget->setCurrentIndex(0);
     ui->tabWidget->setCurrentIndex(0);
     ui->stackedWidget->setCurrentIndex(0);
+
+    // Restore last network info update time
+    qulonglong lastNetInfoUpdate = conf()->get(Config::lastNetInfoUpdate).toULongLong();
+    if (lastNetInfoUpdate > 0) {
+        m_lastNetInfoUpdate = QDateTime::fromSecsSinceEpoch(lastNetInfoUpdate);
+    }
 }
 
 void MainWindow::initMenu() {
@@ -871,13 +878,13 @@ void MainWindow::updateSyncStatusToolTip() {
     quint64 walletHeight = m_wallet->blockChainHeight();
     quint64 targetHeight = m_wallet->daemonBlockChainTargetHeight();
 
-    // 1. Calculate Real Lag (If connected)
+    // 1. Calculate real lag (if connected)
     quint64 blocksBehind = 0;
     if (targetHeight > walletHeight) {
         blocksBehind = targetHeight - walletHeight;
-    } 
-    
-    // 2. Calculate Estimated Lag (If Paused/Offline)
+    }
+
+    // 2. Calculate estimate lag (if paused or offline)
     // Only use time-estimation if we don't have a live connection
     bool isPaused = conf()->get(Config::syncPaused).toBool();
     if (isPaused || m_wallet->connectionStatus() == Wallet::ConnectionStatus_Disconnected) {
@@ -891,7 +898,7 @@ void MainWindow::updateSyncStatusToolTip() {
         }
     }
 
-    // 3. Build the String
+    // 3. Build status tooltip
     QString tooltip = tr("Wallet Height: %1").arg(QLocale().toString(walletHeight));
 
     // Only show Network Tip if we are actually connected
@@ -900,8 +907,10 @@ void MainWindow::updateSyncStatusToolTip() {
             tooltip += tr(" | Network Tip: %1").arg(QLocale().toString(targetHeight));
     }
 
-    if (m_wallet->lastSyncTime().isValid()) {
-        tooltip += tr("\nLast synchronized: %1").arg(Utils::timeAgo(m_wallet->lastSyncTime()));
+    if (conf()->get(Config::lastNetInfoUpdate).toULongLong() > 0) {
+        tooltip += tr("\nLast network update: %1").arg(
+            Utils::timeAgo(QDateTime::fromSecsSinceEpoch(conf()->get(Config::lastNetInfoUpdate).toULongLong()))
+        );
     }
 
     if (blocksBehind > 0) {
@@ -910,7 +919,7 @@ void MainWindow::updateSyncStatusToolTip() {
              tooltip += tr("\n~%1 blocks behind").arg(QLocale().toString(blocksBehind));
         }
     } else if (isPaused) {
-         tooltip += tr("\n(Up to date)");
+         tooltip += tr("\n(Sync paused. Mempool alive.)");
     }
 
     m_statusLabelStatus->setToolTip(tooltip);
@@ -1034,6 +1043,14 @@ void MainWindow::onMultiBroadcast(const QMap<QString, QString> &txHexMap) {
 void MainWindow::onSyncStatus(quint64 height, quint64 target, bool daemonSync) {
     m_lastNetInfoUpdate = QDateTime::currentDateTime();
 
+    // Persist to global config (throttled to syncInterval)
+    static QDateTime lastConfigSave = QDateTime::currentDateTime();
+    int interval = conf()->get(Config::syncInterval).toInt();
+    if (lastConfigSave.secsTo(QDateTime::currentDateTime()) > interval) {
+        conf()->set(Config::lastNetInfoUpdate, static_cast<qulonglong>(m_lastNetInfoUpdate.toSecsSinceEpoch()));
+        lastConfigSave = QDateTime::currentDateTime();
+    }
+
     // qDebug() << "onSyncStatus: Height" << height << "Target" << target << "DaemonSync" << daemonSync;
 
     quint64 blocksBehind = Utils::blocksBehind(height, target);
index a894e177f4bd646f50f5b13f91a9c2bd60a19670..360b3662e368f0ec1bcdc8947884fd9bd8a41ada 100644 (file)
@@ -63,10 +63,6 @@ void WebsocketClient::start() {
         return;
     }
 
-    if (conf()->get(Config::syncPaused).toBool() && conf()->get(Config::syncPausedAlsoDisconnectWebSocket).toBool()) {
-        return;
-    }
-
     // connect & reconnect on errors/close
     auto state = webSocket->state();
     if (state != QAbstractSocket::ConnectedState && state != QAbstractSocket::ConnectingState) {
index bfb5c42123a422fe1cd79d5f7a7610906777cc7a..ae6cade9f830538d245b489a89b70deec21da3f2 100644 (file)
@@ -80,11 +80,12 @@ static const QHash<Config::ConfigKey, ConfigDirective> configStrings = {
         {Config::disableAutoRefresh, {QS("disableAutoRefresh"), false}},
         {Config::offlineMode, {QS("offlineMode"), false}},
         {Config::syncPaused, {QS("syncPaused"), false}},
-        {Config::syncPausedAlsoDisconnectWebSocket, {QS("syncPausedAlsoDisconnectWebSocket"), false}},
+
         {Config::syncInterval, {QS("syncInterval"), 30}},
         {Config::lastKnownNetworkHeight, {QS("lastKnownNetworkHeight"), 0}},
         {Config::lastSyncTimestamp, {QS("lastSyncTimestamp"), 0}},
         {Config::lastPriceUpdateTimestamp, {QS("lastPriceUpdateTimestamp"), 0}},
+        {Config::lastNetInfoUpdate, {QS("lastNetInfoUpdate"), 0}},
 
         // Transactions
         {Config::multiBroadcast, {QS("multiBroadcast"), true}},
index f86d6b7d58e49a968eb7eaabd7581e619e67f1a0..b739359b05f6e47909f882df97308c4431201baa 100644 (file)
@@ -145,9 +145,9 @@ public:
 
         // Sync & data saver
         syncPaused,
-        syncPausedAlsoDisconnectWebSocket,
         syncInterval,
         lastKnownNetworkHeight,
+        lastNetInfoUpdate,
         lastSyncTimestamp,
         lastPriceUpdateTimestamp,
     };