feat(remote): sync shuffle/repeat between desktop and PWA

- Add shuffle/repeat fields to PlaybackEvent struct
- Emit queue:state event when shuffle/repeat changes via API
- Add queue event listener in desktop frontend
- Include shuffle/repeat in WebSocket broadcasts
- PWA updates shuffle/repeat from WebSocket messages

This enables bidirectional sync: changes from PWA update desktop UI,
and changes from desktop update PWA via WebSocket.
This commit is contained in:
vicrodh committed 2026-02-03 09:22:55 -06:00
1 parent 6b85086b0a
commit 477258d94a
5 files changed
+90 -3

No files matched your search

+10
View File
@@ -415,6 +415,14 @@ pub fn run() {
if should_emit {
let sample_rate = player_state.get_sample_rate();
let bit_depth = player_state.get_bit_depth();
// Get queue state for shuffle/repeat
let queue_state = &app_handle.state::<AppState>().queue;
let shuffle = queue_state.is_shuffle();
let repeat = match queue_state.get_repeat() {
queue::RepeatMode::Off => "off",
queue::RepeatMode::All => "all",
queue::RepeatMode::One => "one",
};
let event = player::PlaybackEvent {
is_playing,
position,
@@ -423,6 +431,8 @@ pub fn run() {
volume,
sample_rate: if sample_rate > 0 { Some(sample_rate) } else { None },
bit_depth: if bit_depth > 0 { Some(bit_depth) } else { None },
shuffle: Some(shuffle),
repeat: Some(repeat.to_string()),
};
let _ = app_handle.emit("playback:state", &event);
api_server::broadcast_playback_event(&app_handle, &event);