Repository: tarkah/tickrs (language: rust)

Issue:
Stocks added on the Summary view default to 1D even if the summary is set to a different duration
Here's an example of what I mean:

![Screenshot](https://user-images.githubusercontent.com/1885701/102748586-4d974480-4317-11eb-88ce-a1d62808f016.png)

To reproduce:

* Add one or more stocks on the detail view, then press `s` to go to the summary
* Swap to a different duration, e.g. 5Y
* Add another stock via `/` on the summary view
* Added stock will display 1D data until a new duration is selected (notice the open-price horizontal line which only displays on 1D charts)


Discussion / hints:
Thanks for opening the issue, good catch! I'll get this fixed asap. 

Fix patch:
diff --git a/src/event.rs b/src/event.rs
index 458c4af..8030d0e 100644
--- a/src/event.rs
+++ b/src/event.rs
@@ -107,7 +107,11 @@ pub fn handle_keys_add_stock(
     if key_event.modifiers.is_empty() || key_event.modifiers == KeyModifiers::SHIFT {
         match key_event.code {
             KeyCode::Enter => {
-                let stock = app.add_stock.enter();
+                let mut stock = app.add_stock.enter();
+
+                if app.previous_mode == app::Mode::DisplaySummary {
+                    stock.set_time_frame(app.summary_time_frame);
+                }
 
                 app.stocks.push(stock);
                 app.current_tab = app.stocks.len() - 1;


Test patch: