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 @@ -550,10 +550,25 @@ pub async fn handle_key_events(
550550 if let Some ( selected_controller) =
551551 app. controller_state . selected ( )
552552 {
553- let controller = & app. controllers [ selected_controller] ;
553+ let controller = app
554+ . controllers
555+ . get_mut ( selected_controller)
556+ . expect ( "Selected controller should be valid" ) ;
557+
554558 if let Some ( index) = app. paired_devices_state . selected ( ) {
555- let device = & controller. paired_devices [ index] ;
556- device. toggle_favorite ( ) ;
559+ match controller. paired_devices . get_mut ( index) {
560+ Some ( device) => {
561+ device. is_favorite = !device. is_favorite ;
562+ }
563+ None => {
564+ Notification :: send (
565+ "Selected device should be valid"
566+ . to_string ( ) ,
567+ NotificationLevel :: Error ,
568+ sender. clone ( ) ,
569+ ) ?;
570+ }
571+ }
557572 }
558573 }
559574 }
You can’t perform that action at this time.
0 commit comments