diff --git a/crates/musyx/src/app.rs b/crates/musyx/src/app.rs index 52e0131..d600055 100644 --- a/crates/musyx/src/app.rs +++ b/crates/musyx/src/app.rs @@ -69,8 +69,6 @@ pub struct App { lyrics: HashMap>>>, /// The synced line last scrolled to. lyric_line: Option, - /// The queue published to Yandex for the list playing now. - server_queue: Option, settings: Settings, /// The OS appearance, used when settings say "Match system". system_mode: Mode, @@ -162,7 +160,6 @@ pub enum Message { Edited(Box), LyricsLoaded(String, Result>, Error>), RetryLyrics, - QueueCreated(Result, Error>), ToastTick, CoverWanted(String), CoverLoaded(String, Option>), @@ -191,7 +188,6 @@ impl App { toast: None, lyrics: HashMap::new(), lyric_line: None, - server_queue: None, settings: Settings::default(), system_mode: Mode::Dark, settings_dirty: None, @@ -421,7 +417,6 @@ impl App { self.likes = LikedIds::default(); self.sheet = None; self.lyrics.clear(); - self.server_queue = None; } Message::Navigate(route) => { self.sheet = None; @@ -571,11 +566,6 @@ impl App { } return self.want_lyrics(); } - Message::QueueCreated(Ok(id)) => self.server_queue = id, - Message::QueueCreated(Err(e)) => { - eprintln!("publish queue: {e}"); - self.server_queue = None; - } Message::ToastTick => { if self.toast_expired() { self.toast = None; @@ -1081,19 +1071,6 @@ impl App { }) .discard() } - Effect::QueueStarted { tracks, index } => Self::publish_queue(client, self.play_context(), tracks, index), - Effect::QueueMoved(index) => match self.server_queue.clone() { - Some(id) => { - let client = client.clone(); - Task::future(async move { - if let Err(e) = client.update_queue_position(&id, index).await { - eprintln!("queue position: {e}"); - } - }) - .discard() - } - None => Task::none(), - }, Effect::Report(report) => { let client = client.clone(); Task::future(async move { diff --git a/crates/musyx/src/app/edit.rs b/crates/musyx/src/app/edit.rs index 7d71bb6..5929b17 100644 --- a/crates/musyx/src/app/edit.rs +++ b/crates/musyx/src/app/edit.rs @@ -5,7 +5,7 @@ use std::sync::Arc; use std::time::{Duration, Instant}; use iced::Task; -use ym_api::{Error, PlaylistId, QueueContext, Track, YmClient}; +use ym_api::{Error, PlaylistId}; use super::{App, Message}; use crate::player; @@ -282,23 +282,6 @@ impl App { }) } - /// Publishes a newly started list to Yandex so other devices can continue it. - pub(super) fn publish_queue(client: &YmClient, context: QueueContext, tracks: Vec, index: usize) -> Task { - let client = client.clone(); - Task::future(async move { client.create_queue(&context, &tracks, index).await }).map(Message::QueueCreated) - } - - /// Where a list being played comes from, judged by the page it was started on. - pub(super) fn play_context(&self) -> QueueContext { - match self.nav.current() { - Route::Album(id) => QueueContext::Album(id), - Route::Artist(id) => QueueContext::Artist(id), - Route::Playlist(id) => QueueContext::Playlist(id), - Route::Collection => QueueContext::MyMusic, - _ => QueueContext::Various, - } - } - pub(super) fn toast_expired(&self) -> bool { self.toast.as_ref().is_some_and(|(_, at)| at.elapsed() >= TOAST) } diff --git a/crates/musyx/src/player/mod.rs b/crates/musyx/src/player/mod.rs index e60ac57..c3c32e0 100644 --- a/crates/musyx/src/player/mod.rs +++ b/crates/musyx/src/player/mod.rs @@ -79,10 +79,6 @@ pub enum Effect { WaveFetch { station: String, session_id: Option, queue: Vec }, WaveFeedback { session_id: String, event: WaveEvent, batch_id: Option }, Report(PlayReport), - /// A new list started: publish it so other devices can continue (`tracks` in play order). - QueueStarted { tracks: Vec, index: usize }, - /// The list moved on to another position. - QueueMoved(usize), } /// A station being played, endlessly topped up. @@ -216,10 +212,6 @@ impl Player { self.queue = Queue::new(tracks.to_vec(), start, self.shuffle); self.skips = 0; self.notice = None; - if let Some(queue) = &self.queue { - let (order, index) = queue.in_order(); - effects.push(Effect::QueueStarted { tracks: order.into_iter().cloned().collect(), index }); - } effects.extend(self.load_current()); return effects; } @@ -545,16 +537,6 @@ impl Player { } fn load_current(&mut self) -> Vec { - let mut effects = self.load_track(); - if self.wave.is_none() - && let Some(queue) = &self.queue - { - effects.push(Effect::QueueMoved(queue.in_order().1)); - } - effects - } - - fn load_track(&mut self) -> Vec { let Some(track) = self.track().cloned() else { return vec![] }; self.generation += 1; self.position = Duration::ZERO; @@ -897,17 +879,6 @@ mod tests { assert!(p.wave_station().is_none()); } - #[test] - fn list_play_publishes_queue_and_moves() { - let mut p = Player::default(); - let tracks: Arc<[Track]> = (0..3).map(|i| track(&i.to_string(), 10)).collect(); - let effects = p.update(Msg::Play { tracks, start: 1, shuffle: None }); - assert!(matches!(&effects[0], Effect::QueueStarted { tracks, index: 1 } if tracks.len() == 3)); - assert!(effects.contains(&Effect::QueueMoved(1))); - let effects = p.update(Msg::Next); - assert!(effects.contains(&Effect::QueueMoved(2))); - } - #[test] fn play_next_and_append() { let mut p = playing(3, 0); diff --git a/crates/musyx/src/player/queue.rs b/crates/musyx/src/player/queue.rs index 432e67f..5622019 100644 --- a/crates/musyx/src/player/queue.rs +++ b/crates/musyx/src/player/queue.rs @@ -161,11 +161,6 @@ impl Queue { true } - /// Items in play order, and the current position in it. - pub fn in_order(&self) -> (Vec<&T>, usize) { - (self.order.iter().map(|&i| &self.items[i]).collect(), self.pos) - } - /// Drops everything after the current item, e.g. when a station's settings change. pub fn clear_upcoming(&mut self) { let keep: Vec = self.order[..=self.pos].to_vec(); @@ -285,9 +280,7 @@ mod tests { q.set_shuffle(true); assert!(q.insert_next(99, |a, b| a == b)); assert_eq!(q.upcoming().next().map(|(_, &x)| x), Some(99)); - let (order, pos) = q.in_order(); - assert_eq!(*order[pos], 1); - assert_eq!(*order[pos + 1], 99); + assert_eq!(*q.current(), 1); } #[test] diff --git a/crates/ym-api/src/client.rs b/crates/ym-api/src/client.rs index 7e3aec2..1e431c6 100644 --- a/crates/ym-api/src/client.rs +++ b/crates/ym-api/src/client.rs @@ -6,7 +6,7 @@ use crate::library::{ AlbumPage, AlbumSummary, ArtistPage, ArtistSummary, LibraryPlaylists, PlaylistId, PlaylistPage, PlaylistSummary, }; -use crate::edit::{LikedIds, Lyrics, QueueContext}; +use crate::edit::{LikedIds, Lyrics}; use crate::discover::{ChartEntry, Genre, Home, SearchKind, SearchResults}; use crate::models::{Stream, Track, best_variant, file_info_stream}; use crate::wave::{PlayReport, Station, WaveBatch, WaveEvent, WaveSettings, iso_millis, numeric_id}; @@ -61,11 +61,6 @@ fn recent_track_ids(history: &yamuse::models::MusicHistory, limit: usize) -> Vec .collect() } -/// A queue id, unless it's the all-zero placeholder Yandex returns for a queue it didn't keep. -fn real_queue_id(id: Option) -> Option { - id.filter(|id| !id.is_empty() && !id.bytes().all(|b| b == b'0')) -} - /// The signed-in user as the UI needs them. #[derive(Debug, Clone, PartialEq, Eq)] pub struct Account { @@ -688,41 +683,6 @@ impl YmClient { Ok(None) } - // ---- Server queue ---- - - /// Publishes what's playing so other devices can continue it. Returns the queue id, - /// or `None` when Yandex didn't keep the queue. - /// - /// Yandex now answers every create with the placeholder id `000000000000000000000000` - /// and lists no queues afterwards, whatever device header is sent (a stable - /// `device_id` was tried): the phone apps sync through Ynison instead. The - /// placeholder is dropped so no position updates go to a queue that doesn't exist. - pub async fn create_queue(&self, context: &QueueContext, tracks: &[Track], current: usize) -> Result> { - let tracks: Vec = tracks - .iter() - .map(|t| { - serde_json::json!({ - "trackId": t.id.split(':').next().unwrap_or(&t.id), - "albumId": t.album.as_ref().map(|a| a.id.to_string()).unwrap_or_default(), - "from": "musyx-desktop", - }) - }) - .collect(); - let body = serde_json::json!({ - "context": context.to_json(), - "tracks": tracks, - "currentIndex": current, - "from": "musyx-desktop", - "isInteractive": true, - }); - Ok(real_queue_id(self.inner.create_queue(&body, None).await?)) - } - - pub async fn update_queue_position(&self, queue_id: &str, index: usize) -> Result<()> { - self.inner.update_queue_position(queue_id, index as i64, None).await?; - Ok(()) - } - /// Downloads an image (covers are a few kilobytes). pub async fn image(&self, url: &str) -> Result> { Ok(yamuse::download::Downloader::new(self.inner.transport(), [url.to_owned()]) @@ -798,14 +758,6 @@ mod tests { assert_eq!(recent_track_ids(&history, 10).len(), 4); } - #[test] - fn placeholder_queue_ids_are_dropped() { - assert_eq!(real_queue_id(Some("000000000000000000000000".into())), None); - assert_eq!(real_queue_id(Some(String::new())), None); - assert_eq!(real_queue_id(None), None); - assert_eq!(real_queue_id(Some("6702a1f0c3".into())).as_deref(), Some("6702a1f0c3")); - } - #[test] fn anonymous_status_is_not_an_account() { assert!(Account::from_status(status(r#"{"account":{"now":"2026-10-15"}}"#)).is_none()); diff --git a/crates/ym-api/src/edit.rs b/crates/ym-api/src/edit.rs index d0fe930..8e9573b 100644 --- a/crates/ym-api/src/edit.rs +++ b/crates/ym-api/src/edit.rs @@ -89,31 +89,6 @@ fn parse_stamp(s: &str) -> Option { Some(Duration::from_millis((min * 60 + whole) * 1000 + millis)) } -/// Where a server queue's tracks come from; other devices show it as "Playing from…". -#[derive(Debug, Clone, PartialEq, Eq)] -pub enum QueueContext { - Album(i64), - Playlist(PlaylistId), - Artist(i64), - /// Liked tracks. - MyMusic, - /// Search results, the chart, anything else. - Various, -} - -impl QueueContext { - pub(crate) fn to_json(&self) -> serde_json::Value { - let (kind, id) = match self { - QueueContext::Album(id) => ("album", id.to_string()), - QueueContext::Playlist(p) => ("playlist", format!("{}:{}", p.owner, p.kind)), - QueueContext::Artist(id) => ("artist", id.to_string()), - QueueContext::MyMusic => ("my_music", String::new()), - QueueContext::Various => ("various", String::new()), - }; - serde_json::json!({ "type": kind, "id": id, "description": "" }) - } -} - #[cfg(test)] mod tests { use super::*; @@ -147,10 +122,4 @@ mod tests { assert_eq!(parse_stamp("00:01.1234"), None); } - #[test] - fn queue_contexts_match_the_api_shape() { - let p = QueueContext::Playlist(PlaylistId { owner: 9, kind: 3 }).to_json(); - assert_eq!(p, serde_json::json!({"type": "playlist", "id": "9:3", "description": ""})); - assert_eq!(QueueContext::MyMusic.to_json()["type"], "my_music"); - } } diff --git a/crates/ym-api/src/lib.rs b/crates/ym-api/src/lib.rs index be69463..4800852 100644 --- a/crates/ym-api/src/lib.rs +++ b/crates/ym-api/src/lib.rs @@ -24,5 +24,5 @@ pub use wave::{ Character, Language, MY_WAVE, Mood, PlayReport, Station, WaveBatch, WaveEvent, WaveSettings, }; pub use discover::{BestMatch, ChartEntry, Genre, Home, Personal, SearchKind, SearchResults, Totals}; -pub use edit::{LikedIds, LyricLine, Lyrics, QueueContext}; +pub use edit::{LikedIds, LyricLine, Lyrics}; pub use error::{Error, Result};