diff --git a/src/command.rs b/src/command.rs index 36d6b8f..4d1ef77 100644 --- a/src/command.rs +++ b/src/command.rs @@ -397,10 +397,10 @@ pub fn parse(input: &str) -> Result, CommandParseError> { } "seek" => { if args.is_empty() { - Err(InsufficientArgs { + return Err(InsufficientArgs { cmd: command.into(), hint: Some("a duration".into()), - })?; + }); } let arg = args.join(" "); let first_char = arg.chars().next(); @@ -429,9 +429,7 @@ pub fn parse(input: &str) -> Result, CommandParseError> { }; let seek_direction = match first_char { // handle i32::MAX < unsigned_millis < u32::MAX gracefully - Some('+') => { - i32::try_from(unsigned_millis).map(|millis| SeekDirection::Relative(millis)) - } + Some('+') => i32::try_from(unsigned_millis).map(SeekDirection::Relative), Some('-') => i32::try_from(unsigned_millis) .map(|millis| SeekDirection::Relative(-millis)), _ => Ok(SeekDirection::Absolute(unsigned_millis)), @@ -718,9 +716,11 @@ pub fn parse(input: &str) -> Result, CommandParseError> { } "redraw" => Command::Redraw, "exec" => Command::Execute(args.join(" ")), - _ => Err(NoSuchCommand { - cmd: command.into(), - })?, // I'm surprised this compiles lol + _ => { + return Err(NoSuchCommand { + cmd: command.into(), + }) + } // I'm surprised this compiles lol }; commands.push(command); } diff --git a/src/main.rs b/src/main.rs index c402a50..ef87094 100644 --- a/src/main.rs +++ b/src/main.rs @@ -94,7 +94,7 @@ struct UserDataInner { #[tokio::main] async fn main() -> Result<(), String> { #[cfg(not(windows))] - print!("\x1b]2;{}\x07", "ncspot"); + print!("\x1b]2;ncspot\x07"); let backends = { let backends: Vec<&str> = audio_backend::BACKENDS.iter().map(|b| b.0).collect(); @@ -231,7 +231,7 @@ async fn main() -> Result<(), String> { .values() .initial_screen .clone() - .unwrap_or("library".to_string()); + .unwrap_or_else(|| "library".to_string()); if layout.has_screen(&initial_screen) { layout.set_screen(initial_screen); } else { diff --git a/src/model/playable.rs b/src/model/playable.rs index f9904bf..b887f20 100644 --- a/src/model/playable.rs +++ b/src/model/playable.rs @@ -61,13 +61,6 @@ impl Playable { } } - pub fn added_at(&self) -> Option> { - match self { - Playable::Track(track) => track.added_at, - Playable::Episode(episode) => episode.added_at, - } - } - pub fn set_added_at(&mut self, added_at: Option>) { match self { Playable::Track(track) => track.added_at = added_at, diff --git a/src/mpris.rs b/src/mpris.rs index 7edebe7..73ab3ea 100644 --- a/src/mpris.rs +++ b/src/mpris.rs @@ -152,12 +152,10 @@ fn get_metadata(playable: Option, spotify: Spotify, library: Arc 1.0, - false => 0.0, - }, - ) + .map(|t| match library.is_saved_track(&Playable::Track(t)) { + true => 1.0, + false => 0.0, + }) .unwrap_or(0.0) as f64, )), ); @@ -608,7 +606,7 @@ fn run_dbus_server( if let Some(tracks) = &playlist.tracks { let should_shuffle = queue.get_shuffle(); queue.clear(); - let index = queue.append_next(&tracks.iter().cloned().collect()); + let index = queue.append_next(&tracks.to_vec()); queue.play(index, should_shuffle, should_shuffle) } } @@ -735,7 +733,6 @@ pub struct MprisManager { tx: mpsc::Sender, queue: Arc, spotify: Spotify, - library: Arc, } impl MprisManager { @@ -750,18 +747,12 @@ impl MprisManager { { let spotify = spotify.clone(); let queue = queue.clone(); - let library = library.clone(); std::thread::spawn(move || { run_dbus_server(ev, spotify.clone(), queue.clone(), library.clone(), rx); }); } - MprisManager { - tx, - queue, - spotify, - library, - } + MprisManager { tx, queue, spotify } } pub fn update(&self) { diff --git a/src/queue.rs b/src/queue.rs index dbc6869..170c034 100644 --- a/src/queue.rs +++ b/src/queue.rs @@ -410,9 +410,9 @@ impl Queue { } } -pub fn send_notification(track_name: &str, cover_url: Option) { +pub fn send_notification(track_name: &str, _cover_url: Option) { #[cfg(all(feature = "notify", feature = "cover"))] - let res = if let Some(u) = cover_url { + let res = if let Some(u) = _cover_url { // download album cover image let path = ui::cover::cache_path_for_url(u.to_string()); diff --git a/src/sharing.rs b/src/sharing.rs index 41a44dc..7e23a06 100644 --- a/src/sharing.rs +++ b/src/sharing.rs @@ -63,11 +63,7 @@ pub fn read_share() -> Option { } } } - if let Some(s) = string { - Some(s) - } else { - None - } + string } else { //use x11 clipboard ClipboardProvider::new() diff --git a/src/spotify.rs b/src/spotify.rs index 196f3d2..b4ae37e 100644 --- a/src/spotify.rs +++ b/src/spotify.rs @@ -47,7 +47,6 @@ pub struct Spotify { pub api: WebApi, elapsed: Arc>>, since: Arc>>, - token_issued: Arc>>, channel: Arc>>>, user: Option, } @@ -66,7 +65,6 @@ impl Spotify { api: WebApi::new(), elapsed: Arc::new(RwLock::new(None)), since: Arc::new(RwLock::new(None)), - token_issued: Arc::new(RwLock::new(None)), channel: Arc::new(RwLock::new(None)), user: None, }; diff --git a/src/ui/contextmenu.rs b/src/ui/contextmenu.rs index a26ef3b..21dbf58 100644 --- a/src/ui/contextmenu.rs +++ b/src/ui/contextmenu.rs @@ -39,7 +39,7 @@ enum ContextMenuAction { SelectArtist(Vec), ShareUrl(String), AddToPlaylist(Box), - ShowRecommendations(Track), + ShowRecommendations(Box), ToggleTrackSavedStatus(Box), } @@ -167,7 +167,7 @@ impl ContextMenu { ); content.add_item( "Similar tracks", - ContextMenuAction::ShowRecommendations(t.clone()), + ContextMenuAction::ShowRecommendations(Box::new(t.clone())), ); content.add_item( match library.is_saved_track(&Playable::Track(t.clone())) { diff --git a/src/ui/listview.rs b/src/ui/listview.rs index 5173f41..94ff761 100644 --- a/src/ui/listview.rs +++ b/src/ui/listview.rs @@ -586,7 +586,7 @@ impl ViewExt for ListView { }; if let Some(mut target) = target { - let view = target.open_recommendations(queue.clone(), library.clone()); + let view = target.open_recommendations(queue, library); return match view { Some(view) => Ok(CommandResult::View(view)), None => Ok(CommandResult::Consumed(None)),