Add configuration change debouncing to game list online status updates

- Add OnConfigurationChanged() slot to debounce rapid configuration changes
- Implement 500ms timer to batch configuration update requests
- Prevents excessive network requests when multiple config changes occur
  in quick succession
- Improves performance and reduces server load

Signed-off-by: Zephyron <zephyron@citron-emu.org>
This commit is contained in:
Zephyron
2025-11-21 17:32:19 +10:00
parent bdab418fbf
commit 188e2a8489
2 changed files with 16 additions and 0 deletions

View File

@@ -683,6 +683,18 @@ play_time_manager{play_time_manager_}, system{system_} {
online_status_timer = new QTimer(this);
connect(online_status_timer, &QTimer::timeout, this, &GameList::UpdateOnlineStatus);
online_status_timer->start(5000); // Your refresh interval
// Configure the new timer for debouncing configuration changes
config_update_timer.setSingleShot(true);
connect(&config_update_timer, &QTimer::timeout, this, &GameList::UpdateOnlineStatus);
}
void GameList::OnConfigurationChanged() {
// This function debounces the update requests. Instead of starting a network
// request immediately, it starts a 500ms timer. If another config change happens,
// the timer is simply reset. The network request will only happen once, 500ms
// after the *last* change was made.
config_update_timer.start(500);
}
void GameList::UnloadController() {

View File

@@ -141,6 +141,9 @@ signals:
void PopulatingCompleted();
void SaveConfig();
public slots:
void OnConfigurationChanged();
private slots:
void OnItemExpanded(const QModelIndex& item);
void OnTextChanged(const QString& new_text);
@@ -201,6 +204,7 @@ private:
ControllerNavigation* controller_navigation = nullptr;
CompatibilityList compatibility_list;
QTimer* online_status_timer;
QTimer config_update_timer; // NEW: Timer for debouncing config changes
friend class GameListSearchField;