Refactor: Make Spotify cloneable

This commit is contained in:
Henrik Friedrichsen
2021-04-03 22:35:08 +02:00
parent 8483653cde
commit 0f573f8247
14 changed files with 49 additions and 62 deletions

View File

@@ -28,7 +28,7 @@ type Metadata = HashMap<String, Variant<Box<dyn RefArg>>>;
struct MprisState(String, Option<Playable>);
fn get_playbackstatus(spotify: Arc<Spotify>) -> String {
fn get_playbackstatus(spotify: Spotify) -> String {
match spotify.get_current_status() {
PlayerEvent::Playing | PlayerEvent::FinishedTrack => "Playing",
PlayerEvent::Paused => "Paused",
@@ -136,7 +136,7 @@ fn get_metadata(playable: Option<Playable>) -> Metadata {
fn run_dbus_server(
ev: EventManager,
spotify: Arc<Spotify>,
spotify: Spotify,
queue: Arc<Queue>,
rx: mpsc::Receiver<MprisState>,
) {
@@ -691,11 +691,11 @@ fn run_dbus_server(
pub struct MprisManager {
tx: mpsc::Sender<MprisState>,
queue: Arc<Queue>,
spotify: Arc<Spotify>,
spotify: Spotify,
}
impl MprisManager {
pub fn new(ev: EventManager, spotify: Arc<Spotify>, queue: Arc<Queue>) -> Self {
pub fn new(ev: EventManager, spotify: Spotify, queue: Arc<Queue>) -> Self {
let (tx, rx) = mpsc::channel::<MprisState>();
{