Fix warnings
This commit is contained in:
@@ -397,10 +397,10 @@ pub fn parse(input: &str) -> Result<Vec<Command>, 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<Vec<Command>, 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<Vec<Command>, 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);
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -61,13 +61,6 @@ impl Playable {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn added_at(&self) -> Option<DateTime<Utc>> {
|
||||
match self {
|
||||
Playable::Track(track) => track.added_at,
|
||||
Playable::Episode(episode) => episode.added_at,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn set_added_at(&mut self, added_at: Option<DateTime<Utc>>) {
|
||||
match self {
|
||||
Playable::Track(track) => track.added_at = added_at,
|
||||
|
||||
21
src/mpris.rs
21
src/mpris.rs
@@ -152,12 +152,10 @@ fn get_metadata(playable: Option<Playable>, spotify: Spotify, library: Arc<Libra
|
||||
Variant(Box::new(
|
||||
playable
|
||||
.and_then(|p| p.track())
|
||||
.map(
|
||||
|t| match library.is_saved_track(&Playable::Track(t.clone())) {
|
||||
true => 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<MprisState>,
|
||||
queue: Arc<Queue>,
|
||||
spotify: Spotify,
|
||||
library: Arc<Library>,
|
||||
}
|
||||
|
||||
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) {
|
||||
|
||||
@@ -410,9 +410,9 @@ impl Queue {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn send_notification(track_name: &str, cover_url: Option<String>) {
|
||||
pub fn send_notification(track_name: &str, _cover_url: Option<String>) {
|
||||
#[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());
|
||||
|
||||
|
||||
@@ -63,11 +63,7 @@ pub fn read_share() -> Option<String> {
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(s) = string {
|
||||
Some(s)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
string
|
||||
} else {
|
||||
//use x11 clipboard
|
||||
ClipboardProvider::new()
|
||||
|
||||
@@ -47,7 +47,6 @@ pub struct Spotify {
|
||||
pub api: WebApi,
|
||||
elapsed: Arc<RwLock<Option<Duration>>>,
|
||||
since: Arc<RwLock<Option<SystemTime>>>,
|
||||
token_issued: Arc<RwLock<Option<SystemTime>>>,
|
||||
channel: Arc<RwLock<Option<mpsc::UnboundedSender<WorkerCommand>>>>,
|
||||
user: Option<String>,
|
||||
}
|
||||
@@ -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,
|
||||
};
|
||||
|
||||
@@ -39,7 +39,7 @@ enum ContextMenuAction {
|
||||
SelectArtist(Vec<Artist>),
|
||||
ShareUrl(String),
|
||||
AddToPlaylist(Box<Track>),
|
||||
ShowRecommendations(Track),
|
||||
ShowRecommendations(Box<Track>),
|
||||
ToggleTrackSavedStatus(Box<Track>),
|
||||
}
|
||||
|
||||
@@ -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())) {
|
||||
|
||||
@@ -586,7 +586,7 @@ impl<I: ListItem + Clone> ViewExt for ListView<I> {
|
||||
};
|
||||
|
||||
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)),
|
||||
|
||||
Reference in New Issue
Block a user