summaryrefslogtreecommitdiff
path: root/Source
diff options
context:
space:
mode:
authorOatmealDome <julian@oatmealdome.me>2025-11-12 00:09:41 -0500
committerOatmealDome <julian@oatmealdome.me>2025-11-12 00:09:41 -0500
commitdf5f351adde6db444265dac2691fab4e0ac37add (patch)
tree07290946b0d749a208c2c41083f1da4d79e1edfe /Source
parent8495e0166819919c3e1b9e162460d749720a0111 (diff)
DolphinAnalytics: Only call ReloadConfig in config changed callback when analytics enabled value changes
Co-authored-by: Simonx22 <simon@oatmealdome.me>
Diffstat (limited to 'Source')
-rw-r--r--Source/Core/Core/DolphinAnalytics.cpp13
-rw-r--r--Source/Core/Core/DolphinAnalytics.h1
2 files changed, 12 insertions, 2 deletions
diff --git a/Source/Core/Core/DolphinAnalytics.cpp b/Source/Core/Core/DolphinAnalytics.cpp
index c84565ec52..5aa7936038 100644
--- a/Source/Core/Core/DolphinAnalytics.cpp
+++ b/Source/Core/Core/DolphinAnalytics.cpp
@@ -57,10 +57,19 @@ void DolphinAnalytics::AndroidSetGetValFunc(std::function<std::string(std::strin
DolphinAnalytics::DolphinAnalytics()
{
+ m_last_analytics_enabled = Config::Get(Config::MAIN_ANALYTICS_ENABLED);
+
ReloadConfig();
MakeBaseBuilder();
- m_config_changed_callback_id = Config::AddConfigChangedCallback([this] { ReloadConfig(); });
+ m_config_changed_callback_id = Config::AddConfigChangedCallback([this] {
+ bool current_analytics_enabled = Config::Get(Config::MAIN_ANALYTICS_ENABLED);
+ if (m_last_analytics_enabled != current_analytics_enabled)
+ {
+ m_last_analytics_enabled = current_analytics_enabled;
+ ReloadConfig();
+ }
+ });
}
DolphinAnalytics::~DolphinAnalytics()
@@ -80,7 +89,7 @@ void DolphinAnalytics::ReloadConfig()
// Install the HTTP backend if analytics support is enabled.
std::unique_ptr<Common::AnalyticsReportingBackend> new_backend;
- if (Config::Get(Config::MAIN_ANALYTICS_ENABLED))
+ if (m_last_analytics_enabled)
{
new_backend = std::make_unique<Common::HttpAnalyticsBackend>(ANALYTICS_ENDPOINT);
}
diff --git a/Source/Core/Core/DolphinAnalytics.h b/Source/Core/Core/DolphinAnalytics.h
index b4ff4877df..595736e821 100644
--- a/Source/Core/Core/DolphinAnalytics.h
+++ b/Source/Core/Core/DolphinAnalytics.h
@@ -203,4 +203,5 @@ private:
std::mutex m_reporter_mutex;
Common::AnalyticsReporter m_reporter;
Config::ConfigChangedCallbackID m_config_changed_callback_id{};
+ bool m_last_analytics_enabled = false;
};