diff --git a/src/invidious.cr b/src/invidious.cr index 0cabd507..2fe2fb42 100644 --- a/src/invidious.cr +++ b/src/invidious.cr @@ -1792,6 +1792,36 @@ post "/data_control" do |env| if user user = user.as(User) + spawn do + # Since import can take a while, if we're not done after 20 seconds + # push out content to prevent timeout. + + # Interesting to note is that Chrome will try to render before the content has finished loading, + # which is why we include a loading icon. Firefox and its derivatives will not see this page, + # instead redirecting immediately once the connection has closed. + + # https://stackoverflow.com/q/2091239 is helpful but not directly applicable here. + + sleep 20.seconds + env.response.puts %() + env.response.puts %() + env.response.puts %() + if env.get("preferences").as(Preferences).dark_mode + env.response.puts %() + else + env.response.puts %() + end + env.response.puts %(