From e4488b4353bf1e71ab761fbaa120ee4537ad954b Mon Sep 17 00:00:00 2001 From: Edgar Ruiz Date: Tue, 5 Sep 2023 15:14:25 -0500 Subject: [PATCH 1/4] Fixes #44 --- R/chattr-app.R | 2 +- man/chattr_app.Rd | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/R/chattr-app.R b/R/chattr-app.R index 9698eb1..f891960 100644 --- a/R/chattr-app.R +++ b/R/chattr-app.R @@ -9,7 +9,7 @@ #' is set to TRUE. #' @export chattr_app <- function(viewer = c("viewer", "dialog"), - as_job = FALSE, + as_job = getOption("chattr.as_job", FALSE), as_job_port = getOption("shiny.port", 7788), as_job_host = getOption("shiny.host", "127.0.0.1")) { td <- chattr_defaults(type = "chat") diff --git a/man/chattr_app.Rd b/man/chattr_app.Rd index a00e76a..5dce71c 100644 --- a/man/chattr_app.Rd +++ b/man/chattr_app.Rd @@ -6,7 +6,7 @@ \usage{ chattr_app( viewer = c("viewer", "dialog"), - as_job = FALSE, + as_job = getOption("chattr.as_job", FALSE), as_job_port = getOption("shiny.port", 7788), as_job_host = getOption("shiny.host", "127.0.0.1") ) From c5304f5b9cf35cc0ab84afda10d66519cc0bc302 Mon Sep 17 00:00:00 2001 From: Edgar Ruiz Date: Thu, 7 Sep 2023 14:44:26 -0500 Subject: [PATCH 2/4] Fixes #43 --- R/app_theme.R | 13 ++++++++++++- R/chattr-app.R | 1 + R/ide.R | 3 ++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/R/app_theme.R b/R/app_theme.R index 7c72a4a..c63e89a 100644 --- a/R/app_theme.R +++ b/R/app_theme.R @@ -1,5 +1,5 @@ app_theme_style <- function(x = NULL) { - if (ide_is_rstudio() && !ch_debug_get()) { + if ((ide_is_rstudio() && !ch_debug_get()) | running_as_job()) { ti <- getThemeInfo() color_bg <- app_theme_rgb_to_hex(ti$background) color_fg <- app_theme_rgb_to_hex(ti$foreground) @@ -118,3 +118,14 @@ app_theme_rgb_to_hex <- function(x) { x2 <- unlist(strsplit(x1, ",")) rgb(x2[1], x2[2], x2[3], maxColorValue = 255) } + +running_as_job <- function(x = NULL) { + if(!is.null(x)) { + ch_env$as_job <- x + } else { + if(is.null(ch_env$as_job)) { + ch_env$as_job <-FALSE + } + } + ch_env$as_job +} diff --git a/R/chattr-app.R b/R/chattr-app.R index f891960..2208869 100644 --- a/R/chattr-app.R +++ b/R/chattr-app.R @@ -51,6 +51,7 @@ chattr_app <- function(viewer = c("viewer", "dialog"), } app_interactive <- function(as_job = FALSE) { + running_as_job(as_job) list(ui = app_ui(), server = app_server) } diff --git a/R/ide.R b/R/ide.R index 3718853..7439f90 100644 --- a/R/ide.R +++ b/R/ide.R @@ -14,7 +14,8 @@ ide_is_rstudio <- function() { if (ch_debug_get()) { return(TRUE) } - ide_current() == "rstudio" + check_rstudio <- try(RStudio.Version(), silent = TRUE) + !inherits(check_rstudio, "try-error") } # -------------------------- UI Identification --------------------------------- From ee357fdc92cdea83cfe2e2c98c11df8540562e69 Mon Sep 17 00:00:00 2001 From: Edgar Ruiz Date: Thu, 7 Sep 2023 14:48:24 -0500 Subject: [PATCH 3/4] Fixes checks --- R/ide.R | 2 ++ 1 file changed, 2 insertions(+) diff --git a/R/ide.R b/R/ide.R index 7439f90..d9f05df 100644 --- a/R/ide.R +++ b/R/ide.R @@ -18,6 +18,8 @@ ide_is_rstudio <- function() { !inherits(check_rstudio, "try-error") } +globalVariables("RStudio.Version") + # -------------------------- UI Identification --------------------------------- ui_current <- function() { From 4f214265b34418b27e69ef596686e2d02b00476a Mon Sep 17 00:00:00 2001 From: Edgar Ruiz Date: Thu, 7 Sep 2023 15:00:53 -0500 Subject: [PATCH 4/4] Updates snapshot --- tests/testthat/_snaps/app_ui.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/testthat/_snaps/app_ui.md b/tests/testthat/_snaps/app_ui.md index 6a0c736..78ee768 100644 --- a/tests/testthat/_snaps/app_ui.md +++ b/tests/testthat/_snaps/app_ui.md @@ -22,7 +22,7 @@ [6] "
" [7] "
" [8] " " - [9] " " + [9] " " [10] "
" [11] "
" [12] "
" @@ -52,7 +52,7 @@ [6] "
" [7] "
" [8] " " - [9] "