From 23cea0962de0e903c8a34b625abef3ca7e38bc39 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Todor=20Kondi=C4=87?= <todor.kondic@uni.lu>
Date: Fri, 22 May 2020 14:28:51 +0200
Subject: [PATCH] api, mix, shiny-ui-base: Adapt to new state and conf creation

---
 R/api.R           | 8 +++-----
 R/mix.R           | 1 -
 R/shiny-ui-base.R | 4 +++-
 3 files changed, 6 insertions(+), 7 deletions(-)

diff --git a/R/api.R b/R/api.R
index 513af2b..342aaf3 100644
--- a/R/api.R
+++ b/R/api.R
@@ -15,13 +15,11 @@
 
 ##' @export
 run <- function(fn_conf) {
-    conf <- read_conf(fn_conf)
-    dir.create(conf$project,
+    m <- new_state(fn_conf=fn_conf,
+                   GUI=F)    
+    dir.create(m$conf$project,
                showWarnings = F,
                recursive = T)
-
-    m <- new_state(conf=conf,
-                   GUI=F)    
     m <- withr::with_dir(new=conf$project,code = run_in_dir(m))
     return(invisible(m))
 }
diff --git a/R/mix.R b/R/mix.R
index 5f21974..293fc42 100644
--- a/R/mix.R
+++ b/R/mix.R
@@ -698,7 +698,6 @@ write_state <- function(m,fn_conf) {
     tab2file(tab=m$input$tab$mzml,file=file.path(m$conf$project,FN_DATA_TAB))
 }
 
-new_state <- function(conf,GUI) {
 read_conf <- function(fn) {
     cf <- yaml::yaml.load_file(fn)
     fnl <- cf$compound$lists
diff --git a/R/shiny-ui-base.R b/R/shiny-ui-base.R
index 418a0a6..7035d4b 100644
--- a/R/shiny-ui-base.R
+++ b/R/shiny-ui-base.R
@@ -103,7 +103,9 @@ list2rev <- function(lst) {
 
 new_rv_state <- function(project) {
     p <- normalizePath(path=project,winslash = '/')
-    x <- react_v(m=list2rev(new_state(list(project=p,data=""),GUI=T)))
+    nc <- new_conf()
+    nc$project <- project
+    x <- react_v(m=list2rev(new_state(conf=nc,GUI=T)))
     x
 }
 
-- 
GitLab