@@ -2,12 +2,12 @@ use anyhow::Result;
22use crossterm:: {
33 event:: { self , Event , KeyCode } ,
44 execute,
5- terminal:: { disable_raw_mode , enable_raw_mode , EnterAlternateScreen , LeaveAlternateScreen } ,
5+ terminal:: { EnterAlternateScreen , LeaveAlternateScreen , disable_raw_mode , enable_raw_mode } ,
66} ;
77use ratatui:: {
8+ Terminal ,
89 backend:: { Backend , CrosstermBackend } ,
910 layout:: Rect ,
10- Terminal ,
1111} ;
1212use std:: {
1313 io,
@@ -423,12 +423,13 @@ impl App {
423423 self . scroll_modal_down ( ) ;
424424 } else if matches ! ( self . active_view, ActiveView :: PacketHistory ) {
425425 let packet_count = self . get_packet_history ( ) . len ( ) ;
426- if packet_count > 0 && self . selected_packet_index < packet_count {
427- if let Some ( packet) = self . get_selected_packet ( ) {
428- self . modal_packet = Some ( packet) ;
429- self . show_packet_modal = true ;
430- self . modal_scroll_offset = 0 ;
431- }
426+ if packet_count > 0
427+ && self . selected_packet_index < packet_count
428+ && let Some ( packet) = self . get_selected_packet ( )
429+ {
430+ self . modal_packet = Some ( packet) ;
431+ self . show_packet_modal = true ;
432+ self . modal_scroll_offset = 0 ;
432433 }
433434 }
434435 }
@@ -767,13 +768,13 @@ impl App {
767768 > = std:: collections:: HashMap :: new ( ) ;
768769
769770 for ( i, host) in hosts. iter ( ) . enumerate ( ) {
770- if let PtpHostState :: TimeReceiver ( receiver_state) = & host. state {
771- if let Some ( transmitter_id) = receiver_state. selected_transmitter_identity {
772- transmitter_to_receiver_indices
773- . entry ( transmitter_id )
774- . or_default ( )
775- . push ( i ) ;
776- }
771+ if let PtpHostState :: TimeReceiver ( receiver_state) = & host. state
772+ && let Some ( transmitter_id) = receiver_state. selected_transmitter_identity
773+ {
774+ transmitter_to_receiver_indices
775+ . entry ( transmitter_id )
776+ . or_default ( )
777+ . push ( i ) ;
777778 }
778779 }
779780
@@ -989,10 +990,10 @@ impl App {
989990
990991 pub fn get_packet_history ( & self ) -> Vec < ParsedPacket > {
991992 // Return packets from the currently selected host
992- if let Some ( ref selected_host_id) = self . selected_host_id {
993- if let Some ( history) = self . ptp_tracker . get_host_packet_history ( * selected_host_id) {
994- return history ;
995- }
993+ if let Some ( ref selected_host_id) = self . selected_host_id
994+ && let Some ( history) = self . ptp_tracker . get_host_packet_history ( * selected_host_id)
995+ {
996+ return history ;
996997 }
997998
998999 Vec :: new ( )
@@ -1056,13 +1057,13 @@ impl App {
10561057
10571058 fn restore_host_selection ( & mut self ) {
10581059 // If we have a stored host ID, try to find it in the current list
1059- if let Some ( ref stored_host_id) = self . selected_host_id {
1060- if let Some ( found_index) = self . find_host_index ( * stored_host_id) {
1061- // Found the stored host, select it
1062- self . selected_index = found_index ;
1063- self . ensure_host_visible ( 20 ) ;
1064- return ;
1065- }
1060+ if let Some ( ref stored_host_id) = self . selected_host_id
1061+ && let Some ( found_index) = self . find_host_index ( * stored_host_id)
1062+ {
1063+ // Found the stored host, select it
1064+ self . selected_index = found_index ;
1065+ self . update_selected_host ( found_index ) ;
1066+ return ;
10661067 }
10671068
10681069 // Either no stored host ID, or stored host not found - clamp current index
@@ -1140,11 +1141,7 @@ impl App {
11401141 pub fn ensure_packet_visible ( & mut self ) {
11411142 let visible_height = if self . visible_packet_height == 0 {
11421143 // Defensive fallback if height hasn't been set yet
1143- if self . packet_history_expanded {
1144- 20
1145- } else {
1146- 8
1147- }
1144+ if self . packet_history_expanded { 20 } else { 8 }
11481145 } else {
11491146 self . visible_packet_height
11501147 } ;
0 commit comments