From e01e59df2440d5d3b20ef829ccf2edf15af1c5d1 Mon Sep 17 00:00:00 2001 From: cryptozoidberg Date: Fri, 4 Sep 2020 22:26:03 +0200 Subject: [PATCH] disabled tray notifications while wallet sync --- src/gui/qt-daemon/application/mainwindow.cpp | 5 +++++ src/wallet/view_iface.h | 2 ++ src/wallet/wallets_manager.cpp | 12 +++++++++++- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/src/gui/qt-daemon/application/mainwindow.cpp b/src/gui/qt-daemon/application/mainwindow.cpp index 80777b98..bdd261eb 100644 --- a/src/gui/qt-daemon/application/mainwindow.cpp +++ b/src/gui/qt-daemon/application/mainwindow.cpp @@ -826,6 +826,11 @@ bool MainWindow::money_transfer(const view::transfer_event_info& tei) //don't show unconfirmed tx if (tei.ti.height == 0) return true; + if (tei.is_wallet_in_sync_process) + { + //don't show notification if it long sync process(mmight cause system freeze) + return true; + } auto amount_str = currency::print_money(tei.ti.amount); std::string title, msg; diff --git a/src/wallet/view_iface.h b/src/wallet/view_iface.h index 0443bde2..4dfbba80 100644 --- a/src/wallet/view_iface.h +++ b/src/wallet/view_iface.h @@ -356,6 +356,7 @@ public: uint64_t balance; uint64_t total_mined; uint64_t wallet_id; + bool is_wallet_in_sync_process; BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE(ti) @@ -363,6 +364,7 @@ public: KV_SERIALIZE(balance) KV_SERIALIZE(total_mined) KV_SERIALIZE(wallet_id) + KV_SERIALIZE(is_wallet_in_sync_process) END_KV_SERIALIZE_MAP() }; diff --git a/src/wallet/wallets_manager.cpp b/src/wallet/wallets_manager.cpp index 9aedac42..ccaca324 100644 --- a/src/wallet/wallets_manager.cpp +++ b/src/wallet/wallets_manager.cpp @@ -32,6 +32,13 @@ return API_RETURN_CODE_WALLET_WRONG_ID; \ auto& name = it->second.w; +#define GET_WALLET_OPTIONS_BY_ID_VOID_RET(wallet_id, name) \ + SHARED_CRITICAL_REGION_LOCAL(m_wallets_lock); \ + auto it = m_wallets.find(wallet_id); \ + if (it == m_wallets.end()) \ + return; \ + auto& name = it->second; + #ifdef MOBILE_WALLET_BUILD #define DAEMON_IDLE_UPDATE_TIME_MS 10000 #define TX_POOL_SCAN_INTERVAL 5 @@ -1763,12 +1770,15 @@ void wallets_manager::on_new_block(size_t wallet_id, uint64_t /*height*/, const } void wallets_manager::on_transfer2(size_t wallet_id, const tools::wallet_public::wallet_transfer_info& wti, uint64_t balance, uint64_t unlocked_balance, uint64_t total_mined) -{ +{ view::transfer_event_info tei = AUTO_VAL_INIT(tei); tei.ti = wti; tei.balance = balance; tei.unlocked_balance = unlocked_balance; tei.wallet_id = wallet_id; + + GET_WALLET_OPTIONS_BY_ID_VOID_RET(wallet_id, w); + tei.is_wallet_in_sync_process = w.long_refresh_in_progress; m_pview->money_transfer(tei); } void wallets_manager::on_pos_block_found(size_t wallet_id, const currency::block& b)