fix: Immediately clear data state on resolution or station ID changes to prevent UI blocking and stale data rendering.
Browse files
server.R
CHANGED
|
@@ -500,6 +500,28 @@ server <- function(input, output, session) {
|
|
| 500 |
fetch_current_token <- reactiveVal(NULL) # To invalidate stale sessions
|
| 501 |
fetch_temp_file <- reactiveVal(NULL)
|
| 502 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 503 |
# Initial Trigger (Debounced Window)
|
| 504 |
window_reactive <- reactive({
|
| 505 |
req(input$date_range)
|
|
|
|
| 500 |
fetch_current_token <- reactiveVal(NULL) # To invalidate stale sessions
|
| 501 |
fetch_temp_file <- reactiveVal(NULL)
|
| 502 |
|
| 503 |
+
# --- Immediate State Clearing to Prevent Main Thread Blocking ---
|
| 504 |
+
# When inputs change, clear data IMMEDIATELY to prevent plots from
|
| 505 |
+
# rendering old data with new settings (e.g. Daily data -> Hourly plots = 3000+ traces)
|
| 506 |
+
# This covers the 500ms debounce gap.
|
| 507 |
+
observeEvent(input$data_resolution,
|
| 508 |
+
{
|
| 509 |
+
loading_status(TRUE)
|
| 510 |
+
station_data(NULL)
|
| 511 |
+
parsed_data_list(list())
|
| 512 |
+
},
|
| 513 |
+
priority = 1000
|
| 514 |
+
)
|
| 515 |
+
|
| 516 |
+
observeEvent(current_station_id(),
|
| 517 |
+
{
|
| 518 |
+
loading_status(TRUE)
|
| 519 |
+
station_data(NULL)
|
| 520 |
+
parsed_data_list(list())
|
| 521 |
+
},
|
| 522 |
+
priority = 1000
|
| 523 |
+
)
|
| 524 |
+
|
| 525 |
# Initial Trigger (Debounced Window)
|
| 526 |
window_reactive <- reactive({
|
| 527 |
req(input$date_range)
|