diff --git a/Cargo.lock b/Cargo.lock index 1fb584b..c37eaa5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1775,9 +1775,9 @@ checksum = "f8dcc9c7d52a811697d2151c701e0d08956f92b0e24136cf4cf27b57a6a0d9bf" [[package]] name = "rand" -version = "0.9.2" +version = "0.9.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1" +checksum = "7ec095654a25171c2124e9e3393a930bddbffdc939556c914957a4c3e0a87166" dependencies = [ "rand_chacha", "rand_core 0.9.5", diff --git a/src/tui/app.rs b/src/tui/app.rs index e029ef2..0f2affc 100644 --- a/src/tui/app.rs +++ b/src/tui/app.rs @@ -451,26 +451,24 @@ impl App { self.play_song(&song); } } - AudioEvent::PositionUpdate { position, duration } => { - // Scrobble check - if !self.scrobble_reported && duration > 0.0 { - let at_50_percent = position >= duration * 0.5; - let at_240s = position >= 240.0; - if at_50_percent || at_240s { - self.scrobble_reported = true; - if let (Some(client), Some(song)) = - (&self.client, &self.player.current_song) - { - let song_id = song.id.clone(); - // Fire-and-forget: spawn async task to avoid blocking UI - let url = client.base_url().to_string(); - let username = client.username().to_string(); - let password = client.password().to_string(); - self.rt.spawn(async move { - let c = SubsonicClient::new(&url, &username, &password); - let _ = c.scrobble(&song_id, true).await; - }); - } + // Scrobble check + AudioEvent::PositionUpdate { position, duration } + if !self.scrobble_reported && duration > 0.0 => + { + let at_50_percent = position >= duration * 0.5; + let at_240s = position >= 240.0; + if at_50_percent || at_240s { + self.scrobble_reported = true; + if let (Some(client), Some(song)) = (&self.client, &self.player.current_song) { + let song_id = song.id.clone(); + // Fire-and-forget: spawn async task to avoid blocking UI + let url = client.base_url().to_string(); + let username = client.username().to_string(); + let password = client.password().to_string(); + self.rt.spawn(async move { + let c = SubsonicClient::new(&url, &username, &password); + let _ = c.scrobble(&song_id, true).await; + }); } } } @@ -1006,18 +1004,16 @@ impl App { } } } - 4 => { - if idx < self.genres.len() { - let genre = self.genres[idx].name.clone(); - if let Some(client) = &self.client - && let Ok(songs) = - self.rt.block_on(client.get_songs_by_genre(&genre, 50, 0)) - { - self.push_nav(); - self.songs = songs; - self.active_tab = 2; - self.tab_selected[2] = Some(0); - } + 4 if idx < self.genres.len() => { + let genre = self.genres[idx].name.clone(); + if let Some(client) = &self.client + && let Ok(songs) = + self.rt.block_on(client.get_songs_by_genre(&genre, 50, 0)) + { + self.push_nav(); + self.songs = songs; + self.active_tab = 2; + self.tab_selected[2] = Some(0); } } _ => {} @@ -1263,16 +1259,14 @@ impl App { } } } - 2 => { - if idx < self.search_artists.len() { - let artist_id = self.search_artists[idx].id.clone(); - if let Some(client) = &self.client - && let Ok((_, albums)) = self.rt.block_on(client.get_artist(&artist_id)) - { - self.albums = albums; - self.active_tab = 0; - self.tab_selected[0] = Some(0); - } + 2 if idx < self.search_artists.len() => { + let artist_id = self.search_artists[idx].id.clone(); + if let Some(client) = &self.client + && let Ok((_, albums)) = self.rt.block_on(client.get_artist(&artist_id)) + { + self.albums = albums; + self.active_tab = 0; + self.tab_selected[0] = Some(0); } } _ => {} diff --git a/src/tui/event.rs b/src/tui/event.rs index 0b548a2..2064418 100644 --- a/src/tui/event.rs +++ b/src/tui/event.rs @@ -34,10 +34,8 @@ impl EventHandler { return; } } - Ok(Event::Resize(w, h)) => { - if tx.send(AppEvent::Resize(w, h)).is_err() { - return; - } + Ok(Event::Resize(w, h)) if tx.send(AppEvent::Resize(w, h)).is_err() => { + return; } _ => {} }