Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: events tracking for settings changes #1523

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 19 additions & 10 deletions src-tauri/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -511,6 +511,7 @@ pub async fn set_p2pool_stats_server_port(
port: Option<u16>,
state: tauri::State<'_, UniverseAppState>,
) -> Result<(), String> {
info!(target: LOG_TARGET, "[set_p2pool_stats_server_port] called with port: {:?}", port);
state
.config
.write()
Expand Down Expand Up @@ -736,6 +737,7 @@ pub async fn reset_settings<'r>(
_window: tauri::Window,
app: tauri::AppHandle,
) -> Result<(), String> {
info!(target: LOG_TARGET, "[reset_settings] Resetting settings, reset_wallet: {:?}", reset_wallet);
stop_all_processes(app.clone(), true).await?;
let network = Network::get_current_or_user_setting_or_default().as_key_str();

Expand Down Expand Up @@ -783,7 +785,6 @@ pub async fn reset_settings<'r>(
if path.is_dir() {
if let Some(file_name) = path.file_name().and_then(|name| name.to_str()) {
if folder_block_list.contains(&file_name) {
debug!(target: LOG_TARGET, "[reset_settings] Skipping {:?} directory", path);
continue;
}
}
Expand All @@ -804,28 +805,23 @@ pub async fn reset_settings<'r>(
.unwrap_or(false);

if !reset_wallet && contains_wallet_config {
debug!(target: LOG_TARGET, "[reset_settings] Skipping {:?} directory because it contains wallet_config.json and reset_wallet is false", path);
continue;
}
if reset_wallet && contains_wallet_config && !is_network_dir {
debug!(target: LOG_TARGET, "[reset_settings] Skipping {:?} directory because it contains wallet_config.json and does not matches network name", path);
continue;
}

debug!(target: LOG_TARGET, "[reset_settings] Removing {:?} directory", path);
remove_dir_all(path.clone()).map_err(|e| {
error!(target: LOG_TARGET, "[reset_settings] Could not remove {:?} directory: {:?}", path, e);
format!("Could not remove directory: {}", e)
})?;
} else {
if let Some(file_name) = path.file_name().and_then(|name| name.to_str()) {
if files_block_list.contains(&file_name) {
debug!(target: LOG_TARGET, "[reset_settings] Skipping {:?} file", path);
continue;
}
}

debug!(target: LOG_TARGET, "[reset_settings] Removing {:?} file", path);
remove_file(path.clone()).map_err(|e| {
error!(target: LOG_TARGET, "[reset_settings] Could not remove {:?} file: {:?}", path, e);
format!("Could not remove file: {}", e)
Expand Down Expand Up @@ -901,6 +897,7 @@ pub async fn set_allow_telemetry(
state: tauri::State<'_, UniverseAppState>,
_app: tauri::AppHandle,
) -> Result<(), String> {
info!(target: LOG_TARGET, "[set_allow_telemetry] called with flag: {:?}", allow_telemetry);
state
.config
.write()
Expand Down Expand Up @@ -934,6 +931,7 @@ pub async fn set_application_language(
state: tauri::State<'_, UniverseAppState>,
application_language: String,
) -> Result<(), String> {
info!(target: LOG_TARGET, "[set_application_language] called with language: {}", application_language);
state
.config
.write()
Expand All @@ -950,6 +948,7 @@ pub async fn set_auto_update(
state: tauri::State<'_, UniverseAppState>,
) -> Result<(), String> {
let timer = Instant::now();
info!(target: LOG_TARGET, "[set_auto_update] called with flag: {:?}", auto_update);
state
.config
.write()
Expand All @@ -971,6 +970,7 @@ pub async fn set_cpu_mining_enabled<'r>(
state: tauri::State<'_, UniverseAppState>,
) -> Result<(), String> {
let timer = Instant::now();
info!(target: LOG_TARGET, "[set_cpu_mining_enabled] called with flag: {:?}", enabled);
let mut config = state.config.write().await;
config
.set_cpu_mining_enabled(enabled)
Expand Down Expand Up @@ -1017,6 +1017,7 @@ pub async fn set_display_mode(
state: tauri::State<'_, UniverseAppState>,
) -> Result<(), String> {
let timer = Instant::now();
info!(target: LOG_TARGET, "[set_display_mode] called with mode: {:?}", display_mode);
state
.config
.write()
Expand All @@ -1037,6 +1038,7 @@ pub async fn set_excluded_gpu_devices(
excluded_gpu_devices: Vec<u8>,
state: tauri::State<'_, UniverseAppState>,
) -> Result<(), String> {
info!(target: LOG_TARGET, "[set_excluded_gpu_devices] called with devices: {:?}", excluded_gpu_devices);
let mut gpu_miner = state.gpu_miner.write().await;
gpu_miner
.set_excluded_device(excluded_gpu_devices)
Expand All @@ -1052,6 +1054,7 @@ pub async fn set_gpu_mining_enabled(
state: tauri::State<'_, UniverseAppState>,
) -> Result<(), String> {
let timer = Instant::now();
info!(target: LOG_TARGET, "[set_gpu_mining_enabled] called with flag: {:?}", enabled);
let mut config = state.config.write().await;
config
.set_gpu_mining_enabled(enabled)
Expand All @@ -1074,7 +1077,7 @@ pub async fn set_mine_on_app_start(
state: tauri::State<'_, UniverseAppState>,
) -> Result<(), String> {
let timer = Instant::now();

info!(target: LOG_TARGET, "[set_mine_on_app_start] called with flag: {:?}", mine_on_app_start);
state
.config
.write()
Expand All @@ -1099,7 +1102,7 @@ pub async fn set_mode(
state: tauri::State<'_, UniverseAppState>,
) -> Result<(), String> {
let timer = Instant::now();
info!(target: LOG_TARGET, "set_mode called with mode: {:?}, custom_max_cpu_usage: {:?}, custom_max_gpu_usage: {:?}", mode, custom_cpu_usage, custom_gpu_usage);
info!(target: LOG_TARGET, "[set_mode] called with mode: {:?}, custom_max_cpu_usage: {:?}, custom_max_gpu_usage: {:?}", mode, custom_cpu_usage, custom_gpu_usage);

state
.config
Expand Down Expand Up @@ -1140,6 +1143,7 @@ pub async fn set_monerod_config(
state: tauri::State<'_, UniverseAppState>,
) -> Result<(), String> {
let timer = Instant::now();
info!(target: LOG_TARGET, "[set_monerod_config] called with use_monero_fail: {:?}, monero_nodes: {:?}", use_monero_fail, monero_nodes);
state
.config
.write()
Expand All @@ -1161,6 +1165,7 @@ pub async fn set_p2pool_enabled(
state: tauri::State<'_, UniverseAppState>,
) -> Result<(), String> {
let timer = Instant::now();
info!(target: LOG_TARGET, "[set_p2pool_enabled] called with flag: {:?}", p2pool_enabled);
state
.config
.write()
Expand Down Expand Up @@ -1241,6 +1246,7 @@ pub async fn set_should_auto_launch(
should_auto_launch: bool,
state: tauri::State<'_, UniverseAppState>,
) -> Result<(), String> {
info!(target: LOG_TARGET, "[set_should_auto_launch] called with flag: {:?}", should_auto_launch);
match state
.config
.write()
Expand Down Expand Up @@ -1274,6 +1280,7 @@ pub async fn set_tor_config(
_app: tauri::AppHandle,
) -> Result<TorConfig, String> {
let timer = Instant::now();
info!(target: LOG_TARGET, "[set_tor_config] called with config: {:?}", config);
let tor_config = state
.tor_manager
.set_tor_config(config)
Expand All @@ -1293,6 +1300,7 @@ pub async fn set_use_tor(
app: tauri::AppHandle,
) -> Result<(), String> {
let timer = Instant::now();
info!(target: LOG_TARGET, "[set_use_tor] called with flag: {:?}", use_tor);
state
.config
.write()
Expand Down Expand Up @@ -1325,6 +1333,7 @@ pub async fn set_visual_mode<'r>(
state: tauri::State<'_, UniverseAppState>,
) -> Result<(), String> {
let timer = Instant::now();
info!(target: LOG_TARGET, "[set_visual_mode] called with flag: {:?}", enabled);
let mut config = state.config.write().await;
config
.set_visual_mode(enabled)
Expand Down Expand Up @@ -1400,6 +1409,7 @@ pub async fn set_audio_enabled(
audio_enabled: bool,
state: tauri::State<'_, UniverseAppState>,
) -> Result<(), String> {
info!(target: LOG_TARGET, "[set_audio_enabled] called with flag: {:?}", audio_enabled);
state
.config
.write()
Expand Down Expand Up @@ -1731,6 +1741,7 @@ pub async fn set_pre_release(
state: tauri::State<'_, UniverseAppState>,
) -> Result<(), String> {
let timer = Instant::now();
info!(target: LOG_TARGET, "[set_pre_release] called with flag: {:?}", pre_release);
state
.config
.write()
Expand All @@ -1739,8 +1750,6 @@ pub async fn set_pre_release(
.await
.map_err(|e| e.to_string())?;

info!(target: LOG_TARGET, "Pre-release set to {}, try_update called", pre_release);

state
.updates_manager
.try_update(app.clone(), true, !pre_release)
Expand Down
Loading