Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
  • Loading branch information
gogonzo committed Aug 16, 2023
1 parent 2e66246 commit e54a865
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 20 deletions.
18 changes: 16 additions & 2 deletions R/init.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ init <- function(data,
footer = tags$p(),
id = character(0)) {
logger::log_trace("init initializing teal app with: data ({ class(data)[1] }).")
data <- teal.data::to_relational_data(data = data)
if (!inherits(data, c("TealData", "tdata", "ddl"))) {
data <- teal.data::to_relational_data(data = data)
}

checkmate::assert_multi_class(data, c("TealData", "tdata", "ddl"))
checkmate::assert_multi_class(modules, c("teal_module", "list", "teal_modules"))
Expand All @@ -138,7 +140,7 @@ init <- function(data,

# resolve modules datanames
datanames <- teal.data::get_dataname(data)
join_keys <- get_join_keys(data)
join_keys <- teal.data::get_join_keys(data)
resolve_modules_datanames <- function(modules) {
if (inherits(modules, "teal_modules")) {
modules$children <- sapply(modules$children, resolve_modules_datanames, simplify = FALSE)
Expand All @@ -147,6 +149,18 @@ init <- function(data,
modules$datanames <- if (identical(modules$datanames, "all")) {
datanames
} else if (is.character(modules$datanames)) {
extra_datanames <- setdiff(modules$datanames, datanames)
if (length(extra_datanames)) {
stop(
sprintf(
"Module %s has datanames that are not available in a 'data':\n %s not in %s",
modules$label,
toString(extra_datanames),
toString(datanames)
)
)
}

datanames_adjusted <- intersect(modules$datanames, datanames)
include_parent_datanames(dataname = datanames_adjusted, join_keys = join_keys)
}
Expand Down
15 changes: 8 additions & 7 deletions R/module_nested_tabs.R
Original file line number Diff line number Diff line change
Expand Up @@ -313,13 +313,14 @@ srv_nested_tabs.teal_module <- function(id, datasets, modules, is_module_specifi
new_tdata(
data,
eventReactive(
trigger_data(),
c(
get_rcode_str_install(),
get_rcode_libraries(),
get_datasets_code(datanames, datasets, hashes),
teal.slice::get_filter_expr(datasets, datanames)
)
trigger_data(), {
c(
get_rcode_str_install(),
get_rcode_libraries(),
get_datasets_code(datanames, datasets, hashes),
teal.slice::get_filter_expr(datasets, datanames)
)
}
),
datasets$get_join_keys(),
metadata
Expand Down
5 changes: 1 addition & 4 deletions R/module_teal.R
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,7 @@ srv_teal <- function(id, modules, raw_data, filter = teal_slices()) {

# loading the data -----
env <- environment()
datasets_reactive <- reactive({
if (is.null(raw_data())) {
return(NULL)
}
datasets_reactive <- eventReactive(raw_data(), ignoreNULL = TRUE, {
env$progress <- shiny::Progress$new(session)
env$progress$set(0.25, message = "Setting data")

Expand Down
8 changes: 1 addition & 7 deletions R/module_teal_with_splash.R
Original file line number Diff line number Diff line change
Expand Up @@ -70,16 +70,10 @@ srv_teal_with_splash <- function(id, data, modules, filter = teal_slices()) {
# raw_data contains TealDataAbstract, i.e. R6 object and container for data
# reactive to get data through delayed loading
# we must leave it inside the server because of callModule which needs to pick up the right session

raw_data <- if (inherits(data, "tdata")) {
reactiveVal(data)
} else if (inherits(data, "ddl")) {
data$server(
ns("startapp_module"),
code = x$code,
offline_args = x$offline_args,
postprocess_fun = x$postprocess_fun
)
data$server("startapp_module", data)
} else if (teal.data::is_pulled(data)) {
reactiveVal(data) # will trigger by setting it
} else {
Expand Down

0 comments on commit e54a865

Please sign in to comment.