From 5d059cc76ebc07051491fbdd98a2d6c2d68a2aa2 Mon Sep 17 00:00:00 2001
From: Kacper Wojciechowski <39823706+jog1t@users.noreply.github.com>
Date: Wed, 20 Nov 2024 21:25:11 +0100
Subject: [PATCH] refactor: call bootstrap before running the app (w/o sdk
update)
---
apps/hub/src/app.tsx | 4 ++--
apps/hub/src/main.tsx | 31 ++++++++++++++++++++++---------
2 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/apps/hub/src/app.tsx b/apps/hub/src/app.tsx
index 56940b67..45306b16 100644
--- a/apps/hub/src/app.tsx
+++ b/apps/hub/src/app.tsx
@@ -49,11 +49,11 @@ function InnerApp() {
return ;
}
-export function App() {
+export function App({ cacheKey }: { cacheKey?: string }) {
return (
diff --git a/apps/hub/src/main.tsx b/apps/hub/src/main.tsx
index 4ffbd7f9..c702cd97 100644
--- a/apps/hub/src/main.tsx
+++ b/apps/hub/src/main.tsx
@@ -3,16 +3,29 @@ import ReactDOM from "react-dom/client";
import { App } from "./app";
import "./index.css";
import { initThirdPartyProviders } from "./components/third-party-providers";
+import { rivetClient } from "./queries/global";
initThirdPartyProviders();
-// biome-ignore lint/style/noNonNullAssertion: it should always be present
-const rootElement = document.getElementById("root")!;
-if (!rootElement.innerHTML) {
- const root = ReactDOM.createRoot(rootElement);
- root.render(
-
-
- ,
- );
+rivetClient.cloud
+ .bootstrap()
+ .then((response) => {
+ // @ts-ignore
+ run({ cacheKey: response.deploy_hash });
+ })
+ .catch(() => {
+ run();
+ });
+
+function run({ cacheKey }: { cacheKey?: string } = {}) {
+ // biome-ignore lint/style/noNonNullAssertion: it should always be present
+ const rootElement = document.getElementById("root")!;
+ if (!rootElement.innerHTML) {
+ const root = ReactDOM.createRoot(rootElement);
+ root.render(
+
+
+ ,
+ );
+ }
}