Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions src/infra/queue/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,18 @@ pub async fn route_queue_event(app: &Arc<Mutex<App>>, event: &IoEvent) -> bool {
return true;
}

// Repeat has no meaning for the queue slot, which plays an explicit list over
// a suspended context. Consume it so a plugin's request never cycles repeat
// on the user's real Spotify device with nothing on screen to show for it;
// the keyboard and MPRIS paths already refuse (#376).
if let IoEvent::Repeat(_) = event {
let mut guard = app.lock().await;
if guard.queue_owns_playback() {
guard.set_status_message("Repeat does not apply to this source", 2);
return true;
}
}

// Transport for the queue slot's own player (Pause / Seek / Volume / Next /
// bare-resume). Only meaningful when a decoded queued track owns the sink;
// compiles out entirely without a queueable decoded source.
Expand Down Expand Up @@ -1408,6 +1420,26 @@ mod tests {
assert!(app.lock().await.native_queue.is_empty());
}

/// A plugin's `set_repeat` while the queue slot owns playback must be
/// refused, not forwarded to Spotify (#376). Without a slot it falls through.
#[cfg(feature = "streaming")]
#[tokio::test]
async fn repeat_is_refused_while_the_queue_slot_owns_playback() {
use crate::infra::queue::QueueNowPlaying;
let app = test_app();
let repeat = IoEvent::Repeat(rspotify::model::enums::RepeatState::Off);
assert!(!route_queue_event(&app, &repeat).await);

app.lock().await.queue_now = Some(QueueNowPlaying::Spotify {
track: track("spotify:track:queued", "Queued"),
});
assert!(route_queue_event(&app, &repeat).await);
assert_eq!(
app.lock().await.status_message.as_deref(),
Some("Repeat does not apply to this source")
);
}

#[cfg(feature = "streaming")]
#[tokio::test]
async fn next_track_is_consumed_by_spotify_queue_slot() {
Expand Down
2 changes: 1 addition & 1 deletion tools/gates.count
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ synthetic_keys_in_mouse_handler = 3 # target 0 (the content-table re-entries
wildcard_arms_in_action_tree = 0 # target 0, must stay 0
view_writes_outside_tui = 12 # target 0 (producers outside tui/ and core/app/ writing App::view)
action_refs_in_tui_handlers = 173 # adoption: may only rise
test_attribute_total = 1770 # adoption: may only rise
test_attribute_total = 1771 # adoption: may only rise
Loading