chore: other small fixes

This commit is contained in:
Henrik Friedrichsen
2025-02-17 10:57:00 +01:00
parent 48e5aea9aa
commit 0cd44e3b52
2 changed files with 4 additions and 4 deletions

View File

@@ -48,7 +48,7 @@ impl Playlist {
} }
pub fn has_track(&self, track_id: &str) -> bool { pub fn has_track(&self, track_id: &str) -> bool {
self.tracks.as_ref().map_or(false, |tracks| { self.tracks.as_ref().is_some_and(|tracks| {
tracks tracks
.iter() .iter()
.any(|track| track.id() == Some(track_id.to_string())) .any(|track| track.id() == Some(track_id.to_string()))

View File

@@ -274,10 +274,10 @@ impl MprisPlayer {
} }
#[zbus(property)] #[zbus(property)]
fn set_volume(&self, mut volume: f64) { fn set_volume(&self, volume: f64) {
log::info!("set volume: {volume}"); log::info!("set volume: {volume}");
volume = volume.clamp(0.0, 1.0); let clamped = volume.clamp(0.0, 1.0);
let vol = (VOLUME_PERCENT as f64) * volume * 100.0; let vol = (VOLUME_PERCENT as f64) * clamped * 100.0;
self.spotify.set_volume(vol as u16, false); self.spotify.set_volume(vol as u16, false);
self.event.trigger(); self.event.trigger();
} }