Pause status timer while modals are open (#3131)
Summary: - pause the status timer while waiting on approval modals - expose deterministic pause/resume helpers to avoid sleep-based tests - simplify bottom pane timer handling now that the widget owns the clock
This commit is contained in:
@@ -162,6 +162,8 @@ impl BottomPane {
|
||||
view.handle_key_event(self, key_event);
|
||||
if !view.is_complete() {
|
||||
self.active_view = Some(view);
|
||||
} else {
|
||||
self.on_active_view_complete();
|
||||
}
|
||||
self.request_redraw();
|
||||
InputResult::None
|
||||
@@ -201,6 +203,8 @@ impl BottomPane {
|
||||
CancellationEvent::Handled => {
|
||||
if !view.is_complete() {
|
||||
self.active_view = Some(view);
|
||||
} else {
|
||||
self.on_active_view_complete();
|
||||
}
|
||||
self.show_ctrl_c_quit_hint();
|
||||
}
|
||||
@@ -381,10 +385,27 @@ impl BottomPane {
|
||||
|
||||
// Otherwise create a new approval modal overlay.
|
||||
let modal = ApprovalModalView::new(request, self.app_event_tx.clone());
|
||||
self.pause_status_timer_for_modal();
|
||||
self.active_view = Some(Box::new(modal));
|
||||
self.request_redraw()
|
||||
}
|
||||
|
||||
fn on_active_view_complete(&mut self) {
|
||||
self.resume_status_timer_after_modal();
|
||||
}
|
||||
|
||||
fn pause_status_timer_for_modal(&mut self) {
|
||||
if let Some(status) = self.status.as_mut() {
|
||||
status.pause_timer();
|
||||
}
|
||||
}
|
||||
|
||||
fn resume_status_timer_after_modal(&mut self) {
|
||||
if let Some(status) = self.status.as_mut() {
|
||||
status.resume_timer();
|
||||
}
|
||||
}
|
||||
|
||||
/// Height (terminal rows) required by the current bottom pane.
|
||||
pub(crate) fn request_redraw(&self) {
|
||||
self.frame_requester.schedule_frame();
|
||||
|
||||
Reference in New Issue
Block a user