Merge pull request #3994

fc26150 libwalletqt: refresh once on wallet opening (selsta)
This commit is contained in:
luigi1111 2022-08-10 12:19:26 -05:00
commit 79d56af921
No known key found for this signature in database
GPG key ID: F4ACA0183641E010
2 changed files with 5 additions and 1 deletions

View file

@ -545,6 +545,7 @@ bool Wallet::refresh(bool historyAndSubaddresses /* = true */)
void Wallet::startRefresh() void Wallet::startRefresh()
{ {
m_refreshEnabled = true; m_refreshEnabled = true;
m_refreshNow = true;
} }
void Wallet::pauseRefresh() void Wallet::pauseRefresh()
@ -1142,6 +1143,7 @@ Wallet::Wallet(Monero::Wallet *w, QObject *parent)
, m_subaddressModel(nullptr) , m_subaddressModel(nullptr)
, m_subaddressAccount(new SubaddressAccount(m_walletImpl->subaddressAccount(), this)) , m_subaddressAccount(new SubaddressAccount(m_walletImpl->subaddressAccount(), this))
, m_subaddressAccountModel(nullptr) , m_subaddressAccountModel(nullptr)
, m_refreshNow(false)
, m_refreshEnabled(false) , m_refreshEnabled(false)
, m_refreshing(false) , m_refreshing(false)
, m_scheduler(this) , m_scheduler(this)
@ -1195,10 +1197,11 @@ void Wallet::startRefreshThread()
{ {
const auto now = std::chrono::steady_clock::now(); const auto now = std::chrono::steady_clock::now();
const auto elapsed = now - last; const auto elapsed = now - last;
if (elapsed >= refreshInterval) if (elapsed >= refreshInterval || m_refreshNow)
{ {
refresh(false); refresh(false);
last = std::chrono::steady_clock::now(); last = std::chrono::steady_clock::now();
m_refreshNow = false;
} }
} }

View file

@ -473,6 +473,7 @@ private:
QString m_daemonPassword; QString m_daemonPassword;
QString m_proxyAddress; QString m_proxyAddress;
mutable QMutex m_proxyMutex; mutable QMutex m_proxyMutex;
std::atomic<bool> m_refreshNow;
std::atomic<bool> m_refreshEnabled; std::atomic<bool> m_refreshEnabled;
std::atomic<bool> m_refreshing; std::atomic<bool> m_refreshing;
WalletListenerImpl *m_walletListener; WalletListenerImpl *m_walletListener;