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
This commit is contained in:
Jack Wills
2024-01-13 23:01:22 +00:00
parent 52d1610ac6
commit a34c046dee
2 changed files with 11 additions and 6 deletions
+10 -5
View File
@@ -470,6 +470,12 @@ impl AppData {
self.get_selected_container().map_or(false, |i| i.is_oxker) 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. /// Find the widths for the strings in the containers panel.
/// So can display nicely and evenly /// So can display nicely and evenly
pub fn get_width(&self) -> Columns { pub fn get_width(&self) -> Columns {
@@ -1815,12 +1821,11 @@ mod tests {
}, },
]; ];
app_data.update_containers(&mut input); app_data.update_containers(&mut input);
let result_post = app_data.get_container_items(); let result_post = app_data.get_container_items();
assert_ne!(&result_pre, result_post); assert_ne!(&result_pre, result_post);
assert_eq!(result_post[0].state, State::Paused); 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] #[test]
+1 -1
View File
@@ -272,7 +272,7 @@ impl InputHandler {
if let Some(command) = option_command { if let Some(command) = option_command {
// Poor way of disallowing commands to be sent to a containerised okxer // 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; return;
}; };
let option_id = self.app_data.lock().get_selected_container_id(); let option_id = self.app_data.lock().get_selected_container_id();