Just format the code :)
This commit is contained in:
parent
9fad1454c1
commit
8226253891
3 changed files with 17 additions and 29 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -190,15 +190,6 @@ dependencies = [
|
||||||
"terminal_size",
|
"terminal_size",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
|
||||||
name = "clap-markdown"
|
|
||||||
version = "0.1.3"
|
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
|
||||||
checksum = "325f50228f76921784b6d9f2d62de6778d834483248eefecd27279174797e579"
|
|
||||||
dependencies = [
|
|
||||||
"clap",
|
|
||||||
]
|
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "clap_derive"
|
name = "clap_derive"
|
||||||
version = "4.1.0"
|
version = "4.1.0"
|
||||||
|
@ -226,7 +217,6 @@ name = "cmus-notify"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"clap",
|
"clap",
|
||||||
"clap-markdown",
|
|
||||||
"confy",
|
"confy",
|
||||||
"id3",
|
"id3",
|
||||||
"image",
|
"image",
|
||||||
|
|
11
src/lib.rs
11
src/lib.rs
|
@ -184,11 +184,7 @@ pub fn track_cover(
|
||||||
};
|
};
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
info!("Trying to get the external cover of \"{path}\".");
|
info!("Trying to get the external cover of \"{path}\".");
|
||||||
if let Ok(Some(cover)) = search_for(
|
if let Ok(Some(cover)) = search_for(&path, max_depth, ®x) {
|
||||||
&path,
|
|
||||||
max_depth,
|
|
||||||
®x,
|
|
||||||
) {
|
|
||||||
#[cfg(feature = "debug")]
|
#[cfg(feature = "debug")]
|
||||||
info!("Found the external cover \"{cover}\".");
|
info!("Found the external cover \"{cover}\".");
|
||||||
return TrackCover::External(cover);
|
return TrackCover::External(cover);
|
||||||
|
@ -233,10 +229,10 @@ pub fn process_template_placeholders(
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
use crate::cmus::player_settings::PlayerSettings;
|
||||||
use std::assert_matches::assert_matches;
|
use std::assert_matches::assert_matches;
|
||||||
use std::str::FromStr;
|
use std::str::FromStr;
|
||||||
use test_context::{test_context, TestContext};
|
use test_context::{test_context, TestContext};
|
||||||
use crate::cmus::player_settings::PlayerSettings;
|
|
||||||
|
|
||||||
struct TestContextWithFullTrack {
|
struct TestContextWithFullTrack {
|
||||||
track: Track,
|
track: Track,
|
||||||
|
@ -262,7 +258,8 @@ mod tests {
|
||||||
#[test]
|
#[test]
|
||||||
fn test_process_path_template(ctx: &TestContextWithFullTrack) {
|
fn test_process_path_template(ctx: &TestContextWithFullTrack) {
|
||||||
let cover_path_template = String::from("{title}/{artist}/{album}/{tracknumber}");
|
let cover_path_template = String::from("{title}/{artist}/{album}/{tracknumber}");
|
||||||
let cover_path = process_template_placeholders(cover_path_template, &ctx.track, &ctx.player_settings);
|
let cover_path =
|
||||||
|
process_template_placeholders(cover_path_template, &ctx.track, &ctx.player_settings);
|
||||||
|
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
cover_path,
|
cover_path,
|
||||||
|
|
|
@ -102,9 +102,7 @@ impl NotificationsHandler {
|
||||||
// Reset the notification
|
// Reset the notification
|
||||||
self.setup_the_notification();
|
self.setup_the_notification();
|
||||||
let path = match &self.settings.cover_path_template {
|
let path = match &self.settings.cover_path_template {
|
||||||
Some(template) => {
|
Some(template) => track.process(template.clone()),
|
||||||
track.process(template.clone())
|
|
||||||
}
|
|
||||||
None => track.path.clone(),
|
None => track.path.clone(),
|
||||||
};
|
};
|
||||||
// Get the track cover and set it to notification
|
// Get the track cover and set it to notification
|
||||||
|
@ -140,14 +138,17 @@ impl NotificationsHandler {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn setup_notification_timeout(&mut self, event: &CmusEvent) {
|
fn setup_notification_timeout(&mut self, event: &CmusEvent) {
|
||||||
use CmusEvent::*;
|
use CmusEvent::*;
|
||||||
self.notification.timeout(match event {
|
self.notification.timeout(
|
||||||
TrackChanged(_, _) => self.settings.timeout(),
|
match event {
|
||||||
StatusChanged(_, _) => self.settings.status_notification_timeout(),
|
TrackChanged(_, _) => self.settings.timeout(),
|
||||||
AAAMode(_, _) => self.settings.aaa_mode_notification_timeout(),
|
StatusChanged(_, _) => self.settings.status_notification_timeout(),
|
||||||
VolumeChanged(_, _) => self.settings.volume_notification_timeout(),
|
AAAMode(_, _) => self.settings.aaa_mode_notification_timeout(),
|
||||||
RepeatChanged(_, _) => self.settings.repeat_notification_timeout(),
|
VolumeChanged(_, _) => self.settings.volume_notification_timeout(),
|
||||||
ShuffleChanged(_, _) => self.settings.shuffle_notification_timeout(),
|
RepeatChanged(_, _) => self.settings.repeat_notification_timeout(),
|
||||||
_ => self.settings.timeout(),
|
ShuffleChanged(_, _) => self.settings.shuffle_notification_timeout(),
|
||||||
} as i32 * 1000);
|
_ => self.settings.timeout(),
|
||||||
|
} as i32
|
||||||
|
* 1000,
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue