@@ -303,15 +303,15 @@ impl App {
303303 _ => { }
304304 }
305305 if let Some ( popup_type) = & self . active_popup {
306- if let Some ( popup) = self . popups . get_mut ( popup_type) {
307- if let Some ( action) = popup. handle_events ( Some ( event. clone ( ) ) ) ? {
308- action_tx. send ( action) ?;
309- }
310- }
311- } else if let Some ( component) = self . components . get_mut ( & self . mode ) {
312- if let Some ( action) = component. handle_events ( Some ( event. clone ( ) ) ) ? {
306+ if let Some ( popup) = self . popups . get_mut ( popup_type)
307+ && let Some ( action) = popup. handle_events ( Some ( event. clone ( ) ) ) ?
308+ {
313309 action_tx. send ( action) ?;
314310 }
311+ } else if let Some ( component) = self . components . get_mut ( & self . mode )
312+ && let Some ( action) = component. handle_events ( Some ( event. clone ( ) ) ) ?
313+ {
314+ action_tx. send ( action) ?;
315315 }
316316 if let Some ( action) = self . header . handle_events ( Some ( event. clone ( ) ) ) ? {
317317 action_tx. send ( action) ?;
@@ -332,10 +332,10 @@ impl App {
332332 } else if key == KeyEvent :: new ( KeyCode :: Char ( 'c' ) , KeyModifiers :: CONTROL ) {
333333 action_tx. send ( Action :: Quit ) ?;
334334 } else if key. code == KeyCode :: Esc && self . active_popup . is_some ( ) {
335- if let Some ( popup_type) = & self . active_popup {
336- if let Some ( popup) = self . popups . get_mut ( popup_type) {
337- popup . handle_key_events ( key ) ? ;
338- }
335+ if let Some ( popup_type) = & self . active_popup
336+ && let Some ( popup) = self . popups . get_mut ( popup_type)
337+ {
338+ popup . handle_key_events ( key ) ? ;
339339 }
340340 // Close the popup
341341 self . active_popup = None ;
@@ -403,21 +403,21 @@ impl App {
403403 }
404404
405405 Action :: ConnectedToCloud ( _) => {
406- if let Some ( popup) = & self . active_popup {
407- if popup == & Popup :: SwitchProject {
408- // Hide popup
409- self . active_popup = None ;
410- }
406+ if let Some ( popup) = & self . active_popup
407+ && popup == & Popup :: SwitchProject
408+ {
409+ // Hide popup
410+ self . active_popup = None ;
411411 }
412412 self . cloud_connected = true ;
413413 self . render ( tui) ?;
414414 }
415415 Action :: CloudChangeScope ( ref scope) => {
416- if let Some ( popup) = & self . active_popup {
417- if popup == & Popup :: SwitchProject {
418- // Hide popup
419- self . active_popup = None ;
420- }
416+ if let Some ( popup) = & self . active_popup
417+ && popup == & Popup :: SwitchProject
418+ {
419+ // Hide popup
420+ self . active_popup = None ;
421421 }
422422 self . render ( tui) ?;
423423 self . cloud_worker_tx
@@ -551,39 +551,36 @@ impl App {
551551 . as_ref ( ) ,
552552 )
553553 . split ( f. area ( ) ) ;
554- if draw_header {
555- if let Err ( e) = self . header . draw ( f, rects[ 0 ] ) {
556- self . action_tx
557- . send ( Action :: Error {
558- msg : format ! ( "Failed to draw: {e:?}" ) ,
559- action : None ,
560- } )
561- . unwrap ( ) ;
562- }
554+ if draw_header && let Err ( e) = self . header . draw ( f, rects[ 0 ] ) {
555+ self . action_tx
556+ . send ( Action :: Error {
557+ msg : format ! ( "Failed to draw: {e:?}" ) ,
558+ action : None ,
559+ } )
560+ . unwrap ( ) ;
563561 }
564562
565- if let Some ( component) = self . components . get_mut ( & self . mode ) {
566- if let Err ( e) = component. draw ( f, rects[ 1 ] ) {
567- error ! ( "Error {:?}" , e ) ;
568- self . action_tx
569- . send ( Action :: Error {
570- msg : format ! ( "Failed to draw: {e:?}" ) ,
571- action : None ,
572- } )
573- . unwrap ( ) ;
574- }
563+ if let Some ( component) = self . components . get_mut ( & self . mode )
564+ && let Err ( e) = component. draw ( f, rects[ 1 ] )
565+ {
566+ error ! ( "Error {:?}" , e ) ;
567+ self . action_tx
568+ . send ( Action :: Error {
569+ msg : format ! ( "Failed to draw: {e:?}" ) ,
570+ action : None ,
571+ } )
572+ . unwrap ( ) ;
575573 }
576- if let Some ( popup_type) = & self . active_popup {
577- if let Some ( popup) = self . popups . get_mut ( popup_type) {
578- if let Err ( e) = popup. draw ( f, f. area ( ) ) {
579- self . action_tx
580- . send ( Action :: Error {
581- msg : format ! ( "Failed to draw: {e:?}" ) ,
582- action : None ,
583- } )
584- . unwrap ( ) ;
585- }
586- }
574+ if let Some ( popup_type) = & self . active_popup
575+ && let Some ( popup) = self . popups . get_mut ( popup_type)
576+ && let Err ( e) = popup. draw ( f, f. area ( ) )
577+ {
578+ self . action_tx
579+ . send ( Action :: Error {
580+ msg : format ! ( "Failed to draw: {e:?}" ) ,
581+ action : None ,
582+ } )
583+ . unwrap ( ) ;
587584 }
588585 } ) ?;
589586 Ok ( ( ) )
0 commit comments