From 98227210cb4d43f32f7a783f643bc6f6ec39a390 Mon Sep 17 00:00:00 2001 From: Benjamin Slingo Date: Thu, 4 Sep 2025 09:08:55 -0400 Subject: [PATCH] Add missing ConfigManager parameter updates to main.rs and server.rs --- src/main.rs | 14 +++++++------- src/server.rs | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/main.rs b/src/main.rs index de15a43..c909a79 100644 --- a/src/main.rs +++ b/src/main.rs @@ -133,7 +133,7 @@ async fn main() -> Result<()> { handle_logout(&config_manager) } Some(Commands::AuthUrl) => { - handle_auth_url(&config).await + handle_auth_url(&config, &config_manager).await } Some(Commands::Server { port }) => { handle_server(&config_manager, &config, port).await @@ -187,7 +187,7 @@ async fn handle_auth( config.spotify.client_secret = client_secret; config_manager.save_config(&config)?; - let client = SpotifyClient::new(config.spotify); + let client = SpotifyClient::new(config.spotify, config_manager.clone()); let auth_url = client.get_authorization_url(Some("spotify-tracker")); let auth_code = match code { @@ -233,7 +233,7 @@ async fn handle_current(config_manager: &ConfigManager, config: &AppConfig) -> R message: "Not authenticated. Run 'spotify-tracker auth' first.".to_string(), })?; - let client = SpotifyClient::new(config.spotify.clone()); + let client = SpotifyClient::new(config.spotify.clone(), config_manager.clone()); client.set_token(token_info).await; match client.get_current_track_with_retry(config.max_retries).await? { @@ -261,7 +261,7 @@ async fn handle_monitor( message: "Not authenticated. Run 'spotify-tracker auth' first.".to_string(), })?; - let client = SpotifyClient::new(config.spotify.clone()); + let client = SpotifyClient::new(config.spotify.clone(), config_manager.clone()); client.set_token(token_info).await; println!("🎵 Monitoring Spotify (Press Ctrl+C to stop)"); @@ -333,14 +333,14 @@ fn handle_logout(config_manager: &ConfigManager) -> Result<()> { Ok(()) } -async fn handle_auth_url(config: &AppConfig) -> Result<()> { +async fn handle_auth_url(config: &AppConfig, config_manager: &ConfigManager) -> Result<()> { if config.spotify.client_id.is_empty() { return Err(SpotifyError::ConfigError(config::ConfigError::NotFound( "Client ID not configured. Run 'spotify-tracker auth' first.".to_string(), ))); } - let client = SpotifyClient::new(config.spotify.clone()); + let client = SpotifyClient::new(config.spotify.clone(), config_manager.clone()); let auth_url = client.get_authorization_url(Some("spotify-tracker")); println!("Authorization URL:"); @@ -391,7 +391,7 @@ async fn handle_server( port: u16, ) -> Result<()> { // Don't require authentication for server mode - it will handle OAuth flow - let client = SpotifyClient::new(config.spotify.clone()); + let client = SpotifyClient::new(config.spotify.clone(), config_manager.clone()); // If we have a token, set it if let Ok(Some(token_info)) = config_manager.load_token() { diff --git a/src/server.rs b/src/server.rs index 36ed4ff..6df4271 100644 --- a/src/server.rs +++ b/src/server.rs @@ -466,7 +466,8 @@ mod tests { #[test] fn test_server_creation() { let config = SpotifyConfig::default(); - let client = SpotifyClient::new(config); + let config_manager = crate::config::ConfigManager::new().unwrap(); + let client = SpotifyClient::new(config, config_manager); let server = SpotifyServer::new(client, 8080); assert_eq!(server.port, 8080);