From f5becf197dabf16747aa2eede244e42afcc7ecbd Mon Sep 17 00:00:00 2001 From: dipterix Date: Fri, 27 Sep 2024 20:37:06 -0400 Subject: [PATCH] Fixed a bug where widget will try to load repository when data is not even loaded --- DESCRIPTION | 2 +- R/preset-analysis-electrode.R | 14 +++++++++++++- R/preset-analysis-range.R | 14 +++++++++++++- R/preset-baseline-choices.R | 14 +++++++++++++- R/preset-condition-groups.R | 14 +++++++++++++- R/preset-import-export-pipeline.R | 14 +++++++++++++- 6 files changed, 66 insertions(+), 6 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 80f86ef..c0383f3 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,7 +1,7 @@ Package: ravedash Type: Package Title: Dashboard System for Reproducible Visualization of 'iEEG' -Version: 0.1.3.33 +Version: 0.1.3.34 Authors@R: c( person("Zhengjia", "Wang", email = "dipterix.wang@gmail.com", role = c("aut", "cre", "cph")) ) diff --git a/R/preset-analysis-electrode.R b/R/preset-analysis-electrode.R index e99a106..4080385 100644 --- a/R/preset-analysis-electrode.R +++ b/R/preset-analysis-electrode.R @@ -28,7 +28,19 @@ presets_analysis_electrode_selector2 <- function( # repository_name <- "repository" get_repo <- function(){ - if(!comp$container$data[['@has']](pipeline_repository)) { + + data_loaded <- isTRUE(shiny::isolate(watch_data_loaded())) + has_repository <- comp$container$data[['@has']](pipeline_repository) + + if(!data_loaded) { + if( has_repository ) { + comp$container$data[["@remove"]](pipeline_repository) + } + return(NULL) + } + + if(!has_repository) { + logger("Trying to get repository object...", level = "trace") repository <- raveio::pipeline_read(var_names = pipeline_repository, pipe_dir = comp$container$pipeline_path) comp$container$data[[pipeline_repository]] <- repository diff --git a/R/preset-analysis-range.R b/R/preset-analysis-range.R index 3ea4fd2..aa2d277 100644 --- a/R/preset-analysis-range.R +++ b/R/preset-analysis-range.R @@ -20,7 +20,19 @@ presets_analysis_ranges <- function( } get_repo <- function(){ - if(!comp$container$data[['@has']](pipeline_repository)) { + + data_loaded <- isTRUE(shiny::isolate(watch_data_loaded())) + has_repository <- comp$container$data[['@has']](pipeline_repository) + + if(!data_loaded) { + if( has_repository ) { + comp$container$data[["@remove"]](pipeline_repository) + } + return(NULL) + } + + if(!has_repository) { + logger("Trying to get repository object...", level = "trace") repository <- raveio::pipeline_read(var_names = pipeline_repository, pipe_dir = comp$container$pipeline_path) comp$container$data[[pipeline_repository]] <- repository diff --git a/R/preset-baseline-choices.R b/R/preset-baseline-choices.R index 46c0358..262c97a 100644 --- a/R/preset-baseline-choices.R +++ b/R/preset-baseline-choices.R @@ -25,7 +25,19 @@ presets_baseline_choices <- function( # repository_name <- "repository" get_repo <- function(){ - if(!comp$container$data[['@has']](pipeline_repository)) { + + data_loaded <- isTRUE(shiny::isolate(watch_data_loaded())) + has_repository <- comp$container$data[['@has']](pipeline_repository) + + if(!data_loaded) { + if( has_repository ) { + comp$container$data[["@remove"]](pipeline_repository) + } + return(NULL) + } + + if(!has_repository) { + logger("Trying to get repository object...", level = "trace") repository <- raveio::pipeline_read(var_names = pipeline_repository, pipe_dir = comp$container$pipeline_path) comp$container$data[[pipeline_repository]] <- repository diff --git a/R/preset-condition-groups.R b/R/preset-condition-groups.R index 7c5734f..2670460 100644 --- a/R/preset-condition-groups.R +++ b/R/preset-condition-groups.R @@ -11,7 +11,19 @@ presets_condition_groups <- function( # component_container$add_components(comp) get_repo <- function(){ - if(!comp$container$data[['@has']](pipeline_repository)) { + + data_loaded <- isTRUE(shiny::isolate(watch_data_loaded())) + has_repository <- comp$container$data[['@has']](pipeline_repository) + + if(!data_loaded) { + if( has_repository ) { + comp$container$data[["@remove"]](pipeline_repository) + } + return(NULL) + } + + if(!has_repository) { + logger("Trying to get repository object...", level = "trace") repository <- raveio::pipeline_read(var_names = pipeline_repository, pipe_dir = comp$container$pipeline_path) comp$container$data[[pipeline_repository]] <- repository diff --git a/R/preset-import-export-pipeline.R b/R/preset-import-export-pipeline.R index 0655067..6b825e2 100644 --- a/R/preset-import-export-pipeline.R +++ b/R/preset-import-export-pipeline.R @@ -28,7 +28,19 @@ presets_import_export_subject_pipeline <- function( # repository_name <- "repository" get_repo <- function(){ - if(!comp$container$data[['@has']](pipeline_repository)) { + + data_loaded <- isTRUE(shiny::isolate(watch_data_loaded())) + has_repository <- comp$container$data[['@has']](pipeline_repository) + + if(!data_loaded) { + if( has_repository ) { + comp$container$data[["@remove"]](pipeline_repository) + } + return(NULL) + } + + if(!has_repository) { + logger("Trying to get repository object...", level = "trace") repository <- raveio::pipeline_read(var_names = pipeline_repository, pipe_dir = comp$container$pipeline_path) comp$container$data[[pipeline_repository]] <- repository