Skip to content

Commit

Permalink
Fixed bug where you couldn't add new params if there was not already one
Browse files Browse the repository at this point in the history
  • Loading branch information
Julien-cpsn committed Feb 21, 2024
1 parent 160a406 commit d1df8c7
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 23 deletions.
24 changes: 21 additions & 3 deletions src/app/app_logic/request.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,9 +68,11 @@ impl App<'_> {
self.collection.items[selected_request_index].params.push(new_param);
}

// In case new params were inputted or deleted
self.update_params_selection();

self.collection.items[selected_request_index].url = final_url.leak();

self.update_inputs();
self.select_request_state();
}

Expand All @@ -84,6 +86,24 @@ impl App<'_> {
}

/* PARAMS */
/// Reset selection of if params are provided, either set it to none
pub fn update_params_selection(&mut self) {
let selected_request_index = self.collection.selected.unwrap();
let selected_request = &self.collection.items[selected_request_index];

match !selected_request.params.is_empty() {
true => {
self.request_param_table.selection = Some((0, 0));
self.request_param_table.left_state.select(Some(0));
self.request_param_table.right_state.select(Some(0));
},
false => {
self.request_param_table.selection = None;
self.request_param_table.left_state.select(None);
self.request_param_table.right_state.select(None);
}
}
}

pub fn toggle_params_table_row(&mut self) {
if self.request_param_table.rows.is_empty() {
Expand Down Expand Up @@ -112,7 +132,6 @@ impl App<'_> {
(_, _) => {}
};

self.update_inputs();
self.select_request_state();
}

Expand Down Expand Up @@ -158,7 +177,6 @@ impl App<'_> {
_ => {}
}

self.update_inputs();
self.select_request_state();
}

Expand Down
21 changes: 1 addition & 20 deletions src/app/request_ui/param_tabs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ impl App<'_> {
}

pub fn load_a_request_param_tab(&mut self) {
self.update_inputs();

match self.request_param_tab {
RequestParamsTabs::Params => self.load_request_params_tab(),
RequestParamsTabs::Auth => self.load_request_auth_param_tab(),
Expand All @@ -54,38 +52,21 @@ impl App<'_> {
}

pub fn load_request_params_tab(&mut self) {
let selected_request_index = self.collection.selected.unwrap();
let selected_request = &self.collection.items[selected_request_index];

match !selected_request.params.is_empty() {
true => {
self.request_param_table.selection = Some((0, 0));
self.request_param_table.left_state.select(Some(0));
self.request_param_table.right_state.select(Some(0));
},
false => {
self.request_param_table.selection = None;
self.request_param_table.left_state.select(None);
self.request_param_table.right_state.select(None);
}
}
self.update_params_selection();

self.request_param_tab = RequestParamsTabs::Params;

self.update_inputs();
}

pub fn load_request_auth_param_tab(&mut self) {
self.auth_text_input_selection.selected = 0;

self.request_param_tab = RequestParamsTabs::Auth;

self.update_inputs();
}

pub fn load_request_body_param_tab(&mut self) {
self.request_param_tab = RequestParamsTabs::Body;

self.update_inputs();
}

Expand Down

0 comments on commit d1df8c7

Please sign in to comment.