mirror of
https://git.citron-emu.org/citron/emulator
synced 2025-12-19 18:53:32 +00:00
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:
@@ -683,6 +683,18 @@ play_time_manager{play_time_manager_}, system{system_} {
|
|||||||
online_status_timer = new QTimer(this);
|
online_status_timer = new QTimer(this);
|
||||||
connect(online_status_timer, &QTimer::timeout, this, &GameList::UpdateOnlineStatus);
|
connect(online_status_timer, &QTimer::timeout, this, &GameList::UpdateOnlineStatus);
|
||||||
online_status_timer->start(5000); // Your refresh interval
|
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() {
|
void GameList::UnloadController() {
|
||||||
|
|||||||
@@ -141,6 +141,9 @@ signals:
|
|||||||
void PopulatingCompleted();
|
void PopulatingCompleted();
|
||||||
void SaveConfig();
|
void SaveConfig();
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
void OnConfigurationChanged();
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void OnItemExpanded(const QModelIndex& item);
|
void OnItemExpanded(const QModelIndex& item);
|
||||||
void OnTextChanged(const QString& new_text);
|
void OnTextChanged(const QString& new_text);
|
||||||
@@ -201,6 +204,7 @@ private:
|
|||||||
ControllerNavigation* controller_navigation = nullptr;
|
ControllerNavigation* controller_navigation = nullptr;
|
||||||
CompatibilityList compatibility_list;
|
CompatibilityList compatibility_list;
|
||||||
QTimer* online_status_timer;
|
QTimer* online_status_timer;
|
||||||
|
QTimer config_update_timer; // NEW: Timer for debouncing config changes
|
||||||
|
|
||||||
friend class GameListSearchField;
|
friend class GameListSearchField;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user