Skip to content

Commit

Permalink
remove filter.show_popup
Browse files Browse the repository at this point in the history
  • Loading branch information
pythops committed Oct 2, 2024
1 parent 459b8d2 commit 3aa6225
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 18 deletions.
18 changes: 3 additions & 15 deletions oryx-tui/src/filter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,6 @@ pub struct Filter {
pub ingress_channel: FilterChannel,
pub egress_channel: FilterChannel,
pub focused_block: FocusedBlock,
//TODO: maybe remove
show_popup: bool,
}

impl Default for Filter {
Expand All @@ -89,7 +87,6 @@ impl Filter {
ingress_channel: FilterChannel::new(),
egress_channel: FilterChannel::new(),
focused_block: FocusedBlock::Interface,
show_popup: false,
}
}

Expand Down Expand Up @@ -137,8 +134,6 @@ impl Filter {
}

pub fn trigger(&mut self) {
self.show_popup = true;

self.network.selected_protocols = self.network.applied_protocols.clone();

self.transport.selected_protocols = self.transport.applied_protocols.clone();
Expand Down Expand Up @@ -302,19 +297,12 @@ impl Filter {
.store(false, std::sync::atomic::Ordering::Relaxed);

self.sync()?;
self.show_popup = false;

Ok(())
}

pub fn handle_key_events(&mut self, key_event: KeyEvent) {
pub fn handle_key_events(&mut self, key_event: KeyEvent, is_update_popup_displayed: bool) {
match key_event.code {
KeyCode::Esc => {
if self.show_popup {
self.show_popup = false
}
}

KeyCode::Tab => match self.focused_block {
FocusedBlock::Interface => {
self.focused_block = FocusedBlock::TransportFilter;
Expand Down Expand Up @@ -345,7 +333,7 @@ impl Filter {
}

FocusedBlock::Apply => {
if self.show_popup {
if is_update_popup_displayed {
self.focused_block = FocusedBlock::TransportFilter;
} else {
self.focused_block = FocusedBlock::Interface;
Expand All @@ -360,7 +348,7 @@ impl Filter {
}

FocusedBlock::TransportFilter => {
if self.show_popup {
if is_update_popup_displayed {
self.focused_block = FocusedBlock::Apply;
self.transport.state.select(None);
} else {
Expand Down
6 changes: 3 additions & 3 deletions oryx-tui/src/handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ pub fn handle_key_events(
}
}
_ => {
app.filter.handle_key_events(key_event);
app.filter.handle_key_events(key_event, false);
}
}
return Ok(());
Expand All @@ -57,7 +57,7 @@ pub fn handle_key_events(
KeyCode::Esc => {
app.active_popup = None;
if popup == ActivePopup::UpdateFilters {
app.filter.handle_key_events(key_event);
app.filter.handle_key_events(key_event, true);
}
}
KeyCode::Enter => {
Expand All @@ -72,7 +72,7 @@ pub fn handle_key_events(
}
_ => {
if popup == ActivePopup::UpdateFilters {
app.filter.handle_key_events(key_event);
app.filter.handle_key_events(key_event, true);
}
}
}
Expand Down

0 comments on commit 3aa6225

Please sign in to comment.