From a34c046dee8d5f4b3eeb9c14d42b8f31047e01a5 Mon Sep 17 00:00:00 2001 From: Jack Wills <32690432+mrjackwills@users.noreply.github.com> Date: Sat, 13 Jan 2024 23:01:22 +0000 Subject: [PATCH] fix: is_oxker_in_container() Check is both is_oxker and running in a container, so that oxker container commands will only be ignored if both are true --- src/app_data/mod.rs | 15 ++++++++++----- src/input_handler/mod.rs | 2 +- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/app_data/mod.rs b/src/app_data/mod.rs index d508310..485eee2 100644 --- a/src/app_data/mod.rs +++ b/src/app_data/mod.rs @@ -470,6 +470,12 @@ impl AppData { self.get_selected_container().map_or(false, |i| i.is_oxker) } + /// Check if selected container is oxker and also that oxker is being run in a container + pub fn is_oxker_in_container(&self) -> bool { + self.get_selected_container() + .map_or(false, |i| i.is_oxker && self.args.in_container) + } + /// Find the widths for the strings in the containers panel. /// So can display nicely and evenly pub fn get_width(&self) -> Columns { @@ -1815,12 +1821,11 @@ mod tests { }, ]; - app_data.update_containers(&mut input); - let result_post = app_data.get_container_items(); - assert_ne!(&result_pre, result_post); + app_data.update_containers(&mut input); + let result_post = app_data.get_container_items(); + assert_ne!(&result_pre, result_post); assert_eq!(result_post[0].state, State::Paused); - assert_eq!(result_post[1].state, State::Dead); - + assert_eq!(result_post[1].state, State::Dead); } #[test] diff --git a/src/input_handler/mod.rs b/src/input_handler/mod.rs index d6736f3..ef630b9 100644 --- a/src/input_handler/mod.rs +++ b/src/input_handler/mod.rs @@ -272,7 +272,7 @@ impl InputHandler { if let Some(command) = option_command { // Poor way of disallowing commands to be sent to a containerised okxer - if self.app_data.lock().is_oxker() { + if self.app_data.lock().is_oxker_in_container() { return; }; let option_id = self.app_data.lock().get_selected_container_id();