Repository: emanuele-em/proxelar (language: rust)

Issue:
Crash when clear the list if a request is selected
**Describe the bug**
The App crashes if you clear the requests list if a request is selected

**To Reproduce**
Steps to reproduce the behavior:
1. wait for some requests
2. Click on 🔍 button on a request
3. Click on 🚫 button (clear button) in the top bar
4. Crash

**Expected behavior**
When we clear the list we expected that the selection to be removed

**Resolution**
Best solution imho is to manage differently the selection with the state struct, with a state struct we can add an `<Option>` field called "selected", before clearing the list we can set that field as `None`. This is only the first solution that came to my mind but I think that it's could be good, I am however open to different and better solutions



Discussion / hints:

Fix patch:
diff --git a/mitm_proxy/src/mitm_proxy.rs b/mitm_proxy/src/mitm_proxy.rs
index 521ee85..96b51c8 100644
--- a/mitm_proxy/src/mitm_proxy.rs
+++ b/mitm_proxy/src/mitm_proxy.rs
@@ -295,6 +295,7 @@ impl MitmProxy {
 
                     if clean_btn.clicked() {
                         self.requests = vec![];
+                        self.state.selected_request = None;
                     }
 
                     ui.separator();


Test patch: