From 14601205a74b6139656f745967d31065ebc21e69 Mon Sep 17 00:00:00 2001 From: Maxime Wack Date: Sun, 8 May 2022 02:46:29 +0200 Subject: [PATCH] Implement direct links to shows Use URL like basename?show=id Default to Game of Thrones if no show, display the current show in the URL Use server-side selectize for performance --- app.R | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/app.R b/app.R index 302539f..52ed23b 100644 --- a/app.R +++ b/app.R @@ -17,13 +17,23 @@ if (shows %>% names %>% is.na %>% which %>% length > 0) ui <- fluidPage( inputPanel(width = "20%", height = "100%", h1("GraphTV"), - selectizeInput("show", "Search show", shows, selected = "tt0944947", width = "600px") + selectizeInput("show", "Search show", NULL, width = "600px") ), plotlyOutput("show_graph", width = "100%", height = "800px") ) server <- function(input, output, session) { + observe({ + queryString <- getQueryString(session) + selected <- ifelse(queryString$show %>% is.null, "tt0944947", queryString$show) + updateSelectizeInput(session, "show", choices = shows, selected = selected, server = T) + }) + + observe({ + updateQueryString(str_c("?show=", input$show), "replace", session) + }) + output$show_graph <- renderPlotly({ req(input$show)