Add missing ConfigManager parameter updates to main.rs and server.rs
This commit is contained in:
parent
084f2d7cb7
commit
98227210cb
14
src/main.rs
14
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() {
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue