refactor: tab-aware prioritized refresh system
Split monolithic refreshData() into independent sub-functions (refreshCoreData, refreshAddressData, refreshTransactionData, refreshEncryptionState) each with its own timer and atomic guard. Per-category timers replace the single 5s refresh_timer_: - core_timer_: balance + blockchain info (5s default) - transaction_timer_: tx list + enrichment (10s default) - address_timer_: z/t address lists (15s default) - peer_timer_: encryption state (10s default) Tab-switching via setCurrentPage() adjusts active intervals so the current tab's data refreshes faster (e.g. 3s core on Overview, 5s transactions on History) while background categories slow down. Use fast_worker_ for core data on Overview tab to avoid blocking behind the main refresh batch. Bump version to 1.1.2.
This commit is contained in:
50
src/app.cpp
50
src/app.cpp
@@ -343,7 +343,10 @@ void App::update()
|
||||
}
|
||||
|
||||
// Update timers
|
||||
refresh_timer_ += io.DeltaTime;
|
||||
core_timer_ += io.DeltaTime;
|
||||
address_timer_ += io.DeltaTime;
|
||||
transaction_timer_ += io.DeltaTime;
|
||||
peer_timer_ += io.DeltaTime;
|
||||
price_timer_ += io.DeltaTime;
|
||||
fast_refresh_timer_ += io.DeltaTime;
|
||||
tx_age_timer_ += io.DeltaTime;
|
||||
@@ -591,20 +594,37 @@ void App::update()
|
||||
transactions_dirty_ = true;
|
||||
addresses_dirty_ = true;
|
||||
last_tx_block_height_ = -1;
|
||||
refresh_timer_ = REFRESH_INTERVAL;
|
||||
core_timer_ = active_core_interval_;
|
||||
transaction_timer_ = active_tx_interval_;
|
||||
address_timer_ = active_addr_interval_;
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
// Regular refresh every 5 seconds
|
||||
// Per-category refresh with tab-aware intervals
|
||||
// Skip when wallet is locked — same reason as above.
|
||||
if (refresh_timer_ >= REFRESH_INTERVAL) {
|
||||
refresh_timer_ = 0.0f;
|
||||
if (state_.connected && !state_.isLocked()) {
|
||||
refreshData();
|
||||
} else if (!connection_in_progress_ &&
|
||||
wizard_phase_ == WizardPhase::None) {
|
||||
if (state_.connected && !state_.isLocked()) {
|
||||
if (core_timer_ >= active_core_interval_) {
|
||||
core_timer_ = 0.0f;
|
||||
refreshCoreData();
|
||||
}
|
||||
if (transaction_timer_ >= active_tx_interval_) {
|
||||
transaction_timer_ = 0.0f;
|
||||
refreshTransactionData();
|
||||
}
|
||||
if (address_timer_ >= active_addr_interval_) {
|
||||
address_timer_ = 0.0f;
|
||||
refreshAddressData();
|
||||
}
|
||||
if (peer_timer_ >= active_peer_interval_) {
|
||||
peer_timer_ = 0.0f;
|
||||
refreshEncryptionState();
|
||||
}
|
||||
} else if (core_timer_ >= active_core_interval_) {
|
||||
core_timer_ = 0.0f;
|
||||
if (!connection_in_progress_ &&
|
||||
wizard_phase_ == WizardPhase::None) {
|
||||
tryConnect();
|
||||
}
|
||||
}
|
||||
@@ -619,7 +639,7 @@ void App::update()
|
||||
|
||||
// Keyboard shortcut: Ctrl+, to open Settings page
|
||||
if (io.KeyCtrl && ImGui::IsKeyPressed(ImGuiKey_Comma)) {
|
||||
current_page_ = ui::NavPage::Settings;
|
||||
setCurrentPage(ui::NavPage::Settings);
|
||||
}
|
||||
|
||||
// Keyboard shortcut: Ctrl+Left/Right to cycle themes
|
||||
@@ -1886,7 +1906,11 @@ void App::renderAntivirusHelpDialog()
|
||||
|
||||
void App::refreshNow()
|
||||
{
|
||||
refresh_timer_ = REFRESH_INTERVAL; // Trigger immediate refresh
|
||||
// Trigger immediate refresh on all categories
|
||||
core_timer_ = active_core_interval_;
|
||||
transaction_timer_ = active_tx_interval_;
|
||||
address_timer_ = active_addr_interval_;
|
||||
peer_timer_ = active_peer_interval_;
|
||||
transactions_dirty_ = true; // Force transaction list update
|
||||
addresses_dirty_ = true; // Force address/balance update
|
||||
last_tx_block_height_ = -1; // Reset tx cache
|
||||
@@ -1909,7 +1933,7 @@ void App::handlePaymentURI(const std::string& uri)
|
||||
pending_label_ = payment.label;
|
||||
|
||||
// Switch to Send page
|
||||
current_page_ = ui::NavPage::Send;
|
||||
setCurrentPage(ui::NavPage::Send);
|
||||
|
||||
// Notify user
|
||||
std::string msg = "Payment request loaded";
|
||||
@@ -1936,7 +1960,7 @@ void App::setCurrentTab(int tab) {
|
||||
ui::NavPage::Settings, // 9 = Settings
|
||||
};
|
||||
if (tab >= 0 && tab < static_cast<int>(sizeof(kTabMap)/sizeof(kTabMap[0])))
|
||||
current_page_ = kTabMap[tab];
|
||||
setCurrentPage(kTabMap[tab]);
|
||||
}
|
||||
|
||||
bool App::startEmbeddedDaemon()
|
||||
|
||||
Reference in New Issue
Block a user