File tree Expand file tree Collapse file tree 2 files changed +18
-7
lines changed Expand file tree Collapse file tree 2 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -44,10 +44,6 @@ impl Device {
4444 Ok ( ( ) )
4545 }
4646
47- pub fn toggle_favorite ( & mut self ) -> ( ) {
48- self . is_favorite = !self . is_favorite ;
49- }
50-
5147 // https://specifications.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html
5248 pub fn get_icon ( name : & str ) -> Option < String > {
5349 match name {
Original file line number Diff line number Diff line change @@ -518,10 +518,25 @@ pub async fn handle_key_events(
518518 if let Some ( selected_controller) =
519519 app. controller_state . selected ( )
520520 {
521- let controller = & app. controllers [ selected_controller] ;
521+ let controller = app
522+ . controllers
523+ . get_mut ( selected_controller)
524+ . expect ( "Selected controller should be valid" ) ;
525+
522526 if let Some ( index) = app. paired_devices_state . selected ( ) {
523- let device = & controller. paired_devices [ index] ;
524- device. toggle_favorite ( ) ;
527+ match controller. paired_devices . get_mut ( index) {
528+ Some ( device) => {
529+ device. is_favorite = !device. is_favorite ;
530+ }
531+ None => {
532+ Notification :: send (
533+ "Selected device should be valid"
534+ . to_string ( ) ,
535+ NotificationLevel :: Error ,
536+ sender. clone ( ) ,
537+ ) ?;
538+ }
539+ }
525540 }
526541 }
527542 }
You can’t perform that action at this time.
0 commit comments