diff --git a/src-tauri/src/setup.rs b/src-tauri/src/setup.rs index 78ae416..caec6df 100644 --- a/src-tauri/src/setup.rs +++ b/src-tauri/src/setup.rs @@ -45,15 +45,32 @@ fn get_expected_config_content(api_key: &str, api_url: &str) -> String { } } -fn normalize_config_content(content: &str) -> String { +fn check_config_has_required_values(content: &str, api_key: &str, api_url: &str) -> bool { + let normalized = content.replace("\r\n", "\n"); + let mut found_api_url = false; + let mut found_api_key = false; - content - .replace("\r\n", "\n") - .lines() - .map(|line| line.trim()) - .filter(|line| !line.is_empty()) - .collect::>() - .join("\n") + for line in normalized.lines() { + let trimmed = line.trim(); + + if trimmed.starts_with("api_url") { + if let Some(value) = trimmed.split('=').nth(1) { + let value = value.trim(); + if value == api_url { + found_api_url = true; + } + } + } else if trimmed.starts_with("api_key") { + if let Some(value) = trimmed.split('=').nth(1) { + let value = value.trim(); + if value == api_key { + found_api_key = true; + } + } + } + } + + found_api_url && found_api_key } #[tauri::command] @@ -72,7 +89,7 @@ pub async fn check_wakatime_config(api_key: String, api_url: String) -> Result Re let config_content = fs::read_to_string(&config_path) .map_err(|e| format!("Failed to read config file: {}", e))?; - let lines: Vec<&str> = config_content.lines().collect(); - let mut found_api_url = false; - let mut found_api_key = false; - let mut found_heartbeat_rate = false; - - for line in lines { - if line.starts_with("api_url =") { - found_api_url = true; - } else if line.starts_with("api_key =") { - found_api_key = true; - } else if line.starts_with("heartbeat_rate_limit_seconds =") { - found_heartbeat_rate = true; - } - } - - if !found_api_url || !found_api_key || !found_heartbeat_rate { - return Err("Config file is missing required fields".to_string()); + if !check_config_has_required_values(&config_content, &api_key, &api_url) { + return Err("Config file is missing required api_url and api_key values".to_string()); } Ok(format!( @@ -191,23 +193,8 @@ pub async fn setup_hackatime_windows(api_key: String, api_url: String) -> Result let config_content = fs::read_to_string(&config_path) .map_err(|e| format!("Failed to read config file: {}", e))?; - let lines: Vec<&str> = config_content.lines().collect(); - let mut found_api_url = false; - let mut found_api_key = false; - let mut found_heartbeat_rate = false; - - for line in lines { - if line.starts_with("api_url =") { - found_api_url = true; - } else if line.starts_with("api_key =") { - found_api_key = true; - } else if line.starts_with("heartbeat_rate_limit_seconds =") { - found_heartbeat_rate = true; - } - } - - if !found_api_url || !found_api_key || !found_heartbeat_rate { - return Err("Config file is missing required fields".to_string()); + if !check_config_has_required_values(&config_content, &api_key, &api_url) { + return Err("Config file is missing required api_url and api_key values".to_string()); } Ok(format!( diff --git a/src/App.vue b/src/App.vue index 99d33ca..8dae1bc 100644 --- a/src/App.vue +++ b/src/App.vue @@ -761,17 +761,21 @@ async function handleInstallNow() {
-
-

- leaderboard -

-
- friends - global +
+

+ leaderboard +

+
+ friends + global +
+
+
+

+ Coming Soon... +

- -
diff --git a/src/components/InsightCard.vue b/src/components/InsightCard.vue index c7c16f1..b57158a 100644 --- a/src/components/InsightCard.vue +++ b/src/components/InsightCard.vue @@ -1,13 +1,13 @@