Skip to content

Commit

Permalink
fix(chromecast): resolve issue with play_next
Browse files Browse the repository at this point in the history
  • Loading branch information
tsirysndr committed Feb 4, 2023
1 parent e0a4b15 commit 125840e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 12 additions & 2 deletions graphql/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -201,13 +201,23 @@ pub fn update_tracks_url<T: RemoteCoverUrl + RemoteTrackUrl>(
}
}

pub fn update_track_url<T: RemoteTrackUrl>(devices: Vec<Device>, result: T) -> Result<T, Error> {
pub fn update_track_url<T: RemoteTrackUrl>(
devices: Vec<Device>,
result: T,
will_play_on_chromecast: bool,
) -> Result<T, Error> {
let base_url = match devices
.clone()
.into_iter()
.find(|device| device.is_current_device)
{
Some(device) => Some(format!("http://{}:{}", device.host, device.port)),
Some(device) => {
let host = match will_play_on_chromecast {
true => device.ip,
false => device.host,
};
Some(format!("http://{}:{}", host, device.port))
}
None => None,
};

Expand Down
2 changes: 1 addition & 1 deletion graphql/src/schema/tracklist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -296,7 +296,7 @@ impl TracklistMutation {
if device.receiver.is_some() {
let receiver = device.receiver.as_mut().unwrap();
let will_play_on_chromecast = receiver.device_type() == "chromecast";
track = update_track_url(devices.clone(), track)?;
track = update_track_url(devices.clone(), track, will_play_on_chromecast)?;
let t: types::Track = track.into();
track = update_cover_url(devices.clone(), t.clone(), will_play_on_chromecast)
.unwrap_or_else(|_| t.clone())
Expand Down

0 comments on commit 125840e

Please sign in to comment.