@@ -641,9 +641,9 @@ impl SpircTask {
641641 SpircCommand :: Next => self . handle_next ( None ) ?,
642642 SpircCommand :: VolumeUp => self . handle_volume_up ( ) ,
643643 SpircCommand :: VolumeDown => self . handle_volume_down ( ) ,
644- SpircCommand :: Shuffle ( shuffle) => self . connect_state . handle_shuffle ( shuffle) ?,
645- SpircCommand :: Repeat ( repeat) => self . connect_state . set_repeat_context ( repeat) ,
646- SpircCommand :: RepeatTrack ( repeat) => self . connect_state . set_repeat_track ( repeat) ,
644+ SpircCommand :: Shuffle ( shuffle) => self . handle_shuffle ( shuffle) ?,
645+ SpircCommand :: Repeat ( repeat) => self . handle_repeat_context ( repeat) ? ,
646+ SpircCommand :: RepeatTrack ( repeat) => self . handle_repeat_track ( repeat) ,
647647 SpircCommand :: SetPosition ( position) => self . handle_seek ( position) ,
648648 SpircCommand :: SetVolume ( volume) => self . set_volume ( volume) ,
649649 SpircCommand :: Load ( command) => self . handle_load ( command, None ) . await ?,
@@ -1010,23 +1010,25 @@ impl SpircTask {
10101010 trace ! ( "seek to {seek_to:?}" ) ;
10111011 self . handle_seek ( seek_to. value )
10121012 }
1013- SetShufflingContext ( shuffle) => self . connect_state . handle_shuffle ( shuffle. value ) ?,
1014- SetRepeatingContext ( repeat_context) => self
1015- . connect_state
1016- . handle_set_repeat ( Some ( repeat_context. value ) , None ) ?,
1017- SetRepeatingTrack ( repeat_track) => self
1018- . connect_state
1019- . handle_set_repeat ( None , Some ( repeat_track. value ) ) ?,
1013+ SetShufflingContext ( shuffle) => self . handle_shuffle ( shuffle. value ) ?,
1014+ SetRepeatingContext ( repeat_context) => {
1015+ self . handle_repeat_context ( repeat_context. value ) ?
1016+ }
1017+ SetRepeatingTrack ( repeat_track) => self . handle_repeat_track ( repeat_track. value ) ,
10201018 AddToQueue ( add_to_queue) => self . connect_state . add_to_queue ( add_to_queue. track , true ) ,
10211019 SetQueue ( set_queue) => self . connect_state . handle_set_queue ( set_queue) ,
10221020 SetOptions ( set_options) => {
1023- let context = set_options. repeating_context ;
1024- let track = set_options. repeating_track ;
1025- self . connect_state . handle_set_repeat ( context, track) ?;
1021+ if let Some ( repeat_context) = set_options. repeating_context {
1022+ self . handle_repeat_context ( repeat_context) ?
1023+ }
1024+
1025+ if let Some ( repeat_track) = set_options. repeating_track {
1026+ self . handle_repeat_track ( repeat_track)
1027+ }
10261028
10271029 let shuffle = set_options. shuffling_context ;
10281030 if let Some ( shuffle) = shuffle {
1029- self . connect_state . handle_shuffle ( shuffle) ?;
1031+ self . handle_shuffle ( shuffle) ?;
10301032 }
10311033 }
10321034 SkipNext ( skip_next) => self . handle_next ( skip_next. track . map ( |t| t. uri ) ) ?,
@@ -1381,6 +1383,23 @@ impl SpircTask {
13811383 } ;
13821384 }
13831385
1386+ fn handle_shuffle ( & mut self , shuffle : bool ) -> Result < ( ) , Error > {
1387+ self . player . emit_shuffle_changed_event ( shuffle) ;
1388+ self . connect_state . handle_shuffle ( shuffle)
1389+ }
1390+
1391+ fn handle_repeat_context ( & mut self , repeat : bool ) -> Result < ( ) , Error > {
1392+ self . player
1393+ . emit_repeat_changed_event ( repeat, self . connect_state . repeat_track ( ) ) ;
1394+ self . connect_state . handle_set_repeat_context ( repeat)
1395+ }
1396+
1397+ fn handle_repeat_track ( & mut self , repeat : bool ) {
1398+ self . player
1399+ . emit_repeat_changed_event ( self . connect_state . repeat_context ( ) , repeat) ;
1400+ self . connect_state . set_repeat_track ( repeat) ;
1401+ }
1402+
13841403 fn handle_preload_next_track ( & mut self ) {
13851404 // Requests the player thread to preload the next track
13861405 match self . play_status {
0 commit comments