Skip to content

Commit

Permalink
Fix: applied clippy suggestions + format
Browse files Browse the repository at this point in the history
  • Loading branch information
haruInDisguise committed Sep 16, 2024
1 parent 2cc6adc commit 29474eb
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 21 deletions.
9 changes: 2 additions & 7 deletions src/application.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ use crate::{authentication, ui, utils};
use crate::{command, queue, spotify};

#[cfg(feature = "mpris")]
use crate::mpris::{self, MprisManager};
use crate::mpris::MprisManager;

#[cfg(unix)]
use crate::ipc::{self, IpcSocket};
Expand Down Expand Up @@ -68,9 +68,6 @@ pub struct Application {
/// Internally shared
event_manager: EventManager,
/// An IPC implementation using the D-Bus MPRIS protocol, used to control and inspect ncspot.
#[cfg(feature = "mpris")]
mpris_manager: MprisManager,
/// An IPC implementation using a Unix domain socket, used to control and inspect ncspot.
#[cfg(unix)]
ipc: Option<IpcSocket>,
/// The object to render to the terminal.
Expand Down Expand Up @@ -130,7 +127,7 @@ impl Application {
));

#[cfg(feature = "mpris")]
let mpris_manager = mpris::MprisManager::new(
let mpris_manager = MprisManager::new(
event_manager.clone(),
queue.clone(),
library.clone(),
Expand Down Expand Up @@ -229,8 +226,6 @@ impl Application {
queue,
spotify,
event_manager,
#[cfg(feature = "mpris")]
mpris_manager,
#[cfg(unix)]
ipc,
cursive,
Expand Down
17 changes: 9 additions & 8 deletions src/mpris.rs
Original file line number Diff line number Diff line change
Expand Up @@ -465,11 +465,12 @@ impl MprisPlayer {
/// Commands to control the [MprisManager] worker thread.
#[derive(Debug)]
pub enum MprisCommand {
/// Notify about playback status and metadata updates.
PlaybackUpdate,
/// Notify about volume updates.
VolumeUpdate,
MetadataUpdate,
/// Emit playback status
Playback,
/// Emit volume
Volume,
/// Emit metadata
Metadata,
}

/// An MPRIS server that internally manager a thread which can be sent commands. This is internally
Expand Down Expand Up @@ -527,14 +528,14 @@ impl MprisManager {
loop {
let ctx = player_iface_ref.signal_context();
match rx.next().await {
Some(MprisCommand::PlaybackUpdate) => {
Some(MprisCommand::Playback) => {
player_iface.playback_status_changed(ctx).await?;
}
Some(MprisCommand::VolumeUpdate) => {
Some(MprisCommand::Volume) => {
info!("sending MPRIS volume update signal");
player_iface.volume_changed(ctx).await?;
}
Some(MprisCommand::MetadataUpdate) => {
Some(MprisCommand::Metadata) => {
player_iface.metadata_changed(ctx).await?;
}
None => break,
Expand Down
2 changes: 1 addition & 1 deletion src/queue.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ use notify_rust::Notification;
use rand::prelude::*;
use strum_macros::Display;

use crate::config::{Config};
use crate::config::Config;
use crate::library::Library;
use crate::model::playable::Playable;
use crate::spotify::PlayerEvent;
Expand Down
10 changes: 5 additions & 5 deletions src/spotify.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ impl Spotify {
));

#[cfg(feature = "mpris")]
self.send_mpris(MprisCommand::MetadataUpdate);
self.send_mpris(MprisCommand::Metadata);
}

/// Update the cached status of the [Player]. This makes sure the status
Expand All @@ -342,8 +342,8 @@ impl Spotify {
let mut status = self.status.write().unwrap();
*status = new_status;

#[cfg(feature ="mpris")]
self.send_mpris(MprisCommand::PlaybackUpdate);
#[cfg(feature = "mpris")]
self.send_mpris(MprisCommand::Playback);
}

/// Reset the time tracking stats for the current song. This should be called when a new song is
Expand All @@ -369,7 +369,7 @@ impl Spotify {
}

/// Send an [MprisCommand] to the mpris thread.
#[cfg(feature ="mpris")]
#[cfg(feature = "mpris")]
fn send_mpris(&self, cmd: MprisCommand) {
debug!("Sending mpris command: {:?}", cmd);
if let Some(mpris_manager) = self.mpris.lock().unwrap().as_ref() {
Expand Down Expand Up @@ -435,7 +435,7 @@ impl Spotify {
// MPRIS implementation.
if notify {
#[cfg(feature = "mpris")]
self.send_mpris(MprisCommand::VolumeUpdate)
self.send_mpris(MprisCommand::Volume)
}
}

Expand Down

0 comments on commit 29474eb

Please sign in to comment.