Just format the code :)

This commit is contained in:
Anas Elgarhy 2023-02-23 13:54:22 +02:00
parent 9fad1454c1
commit 8226253891
No known key found for this signature in database
GPG key ID: 0501802A1D496528
3 changed files with 17 additions and 29 deletions

10
Cargo.lock generated
View file

@ -190,15 +190,6 @@ dependencies = [
"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]]
name = "clap_derive"
version = "4.1.0"
@ -226,7 +217,6 @@ name = "cmus-notify"
version = "0.1.0"
dependencies = [
"clap",
"clap-markdown",
"confy",
"id3",
"image",

View file

@ -184,11 +184,7 @@ pub fn track_cover(
};
#[cfg(feature = "debug")]
info!("Trying to get the external cover of \"{path}\".");
if let Ok(Some(cover)) = search_for(
&path,
max_depth,
&regx,
) {
if let Ok(Some(cover)) = search_for(&path, max_depth, &regx) {
#[cfg(feature = "debug")]
info!("Found the external cover \"{cover}\".");
return TrackCover::External(cover);
@ -233,10 +229,10 @@ pub fn process_template_placeholders(
#[cfg(test)]
mod tests {
use super::*;
use crate::cmus::player_settings::PlayerSettings;
use std::assert_matches::assert_matches;
use std::str::FromStr;
use test_context::{test_context, TestContext};
use crate::cmus::player_settings::PlayerSettings;
struct TestContextWithFullTrack {
track: Track,
@ -262,7 +258,8 @@ mod tests {
#[test]
fn test_process_path_template(ctx: &TestContextWithFullTrack) {
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!(
cover_path,

View file

@ -102,9 +102,7 @@ impl NotificationsHandler {
// Reset the notification
self.setup_the_notification();
let path = match &self.settings.cover_path_template {
Some(template) => {
track.process(template.clone())
}
Some(template) => track.process(template.clone()),
None => track.path.clone(),
};
// Get the track cover and set it to notification
@ -140,14 +138,17 @@ impl NotificationsHandler {
#[inline(always)]
fn setup_notification_timeout(&mut self, event: &CmusEvent) {
use CmusEvent::*;
self.notification.timeout(match event {
TrackChanged(_, _) => self.settings.timeout(),
StatusChanged(_, _) => self.settings.status_notification_timeout(),
AAAMode(_, _) => self.settings.aaa_mode_notification_timeout(),
VolumeChanged(_, _) => self.settings.volume_notification_timeout(),
RepeatChanged(_, _) => self.settings.repeat_notification_timeout(),
ShuffleChanged(_, _) => self.settings.shuffle_notification_timeout(),
_ => self.settings.timeout(),
} as i32 * 1000);
self.notification.timeout(
match event {
TrackChanged(_, _) => self.settings.timeout(),
StatusChanged(_, _) => self.settings.status_notification_timeout(),
AAAMode(_, _) => self.settings.aaa_mode_notification_timeout(),
VolumeChanged(_, _) => self.settings.volume_notification_timeout(),
RepeatChanged(_, _) => self.settings.repeat_notification_timeout(),
ShuffleChanged(_, _) => self.settings.shuffle_notification_timeout(),
_ => self.settings.timeout(),
} as i32
* 1000,
);
}
}