|
1 | 1 | use anyhow::Context; |
| 2 | +use rspotify::model::Id; |
2 | 3 | use tracing::Instrument; |
3 | 4 |
|
4 | 5 | use crate::{ |
5 | 6 | config, |
6 | 7 | state::{ContextId, ContextPageType, ContextPageUIState, PageState, PlayableId, SharedState}, |
7 | 8 | }; |
8 | 9 |
|
9 | | -#[cfg(feature = "lyric-finder")] |
10 | 10 | use crate::utils::map_join; |
11 | 11 |
|
12 | 12 | use super::ClientRequest; |
@@ -167,25 +167,24 @@ fn handle_page_change_event( |
167 | 167 | } |
168 | 168 | } |
169 | 169 |
|
170 | | - #[cfg(feature = "lyric-finder")] |
171 | | - PageState::Lyric { |
| 170 | + PageState::Lyrics { |
| 171 | + track_uri, |
172 | 172 | track, |
173 | 173 | artists, |
174 | | - scroll_offset, |
175 | 174 | } => { |
176 | 175 | if let Some(rspotify::model::PlayableItem::Track(current_track)) = |
177 | 176 | state.player.read().currently_playing() |
178 | 177 | { |
179 | 178 | if current_track.name != *track { |
180 | | - tracing::info!("Current playing track \"{}\" is different from the track \"{track}\" shown up in the lyric page. Updating the track and fetching its lyric...", current_track.name); |
181 | | - track.clone_from(¤t_track.name); |
182 | | - *artists = map_join(¤t_track.artists, |a| &a.name, ", "); |
183 | | - *scroll_offset = 0; |
184 | | - |
185 | | - client_pub.send(ClientRequest::GetLyric { |
186 | | - track: track.clone(), |
187 | | - artists: artists.clone(), |
188 | | - })?; |
| 179 | + if let Some(id) = ¤t_track.id { |
| 180 | + tracing::info!("Currently playing track \"{}\" is different from the track \"{track}\" shown up in the lyrics page. Fetching new track's lyrics...", current_track.name); |
| 181 | + track.clone_from(¤t_track.name); |
| 182 | + *artists = map_join(¤t_track.artists, |a| &a.name, ", "); |
| 183 | + *track_uri = id.uri(); |
| 184 | + client_pub.send(ClientRequest::GetLyrics { |
| 185 | + track_id: id.clone_static(), |
| 186 | + })?; |
| 187 | + } |
189 | 188 | } |
190 | 189 | } |
191 | 190 | } |
|
0 commit comments