Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: call bootstrap before running the app (w/o sdk update) #399

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions apps/hub/src/app.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ function InnerApp() {
return <RouterProvider router={router} context={{ auth }} />;
}

export function App() {
export function App({ cacheKey }: { cacheKey?: string }) {
return (
<PersistQueryClientProvider
client={queryClient}
persistOptions={{ persister: queryClientPersister }}
persistOptions={{ persister: queryClientPersister, buster: cacheKey }}
>
<ConfigProvider value={getConfig()}>
<ThirdPartyProviders>
Expand Down
31 changes: 22 additions & 9 deletions apps/hub/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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(
<StrictMode>
<App />
</StrictMode>,
);
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(
<StrictMode>
<App cacheKey={cacheKey} />
</StrictMode>,
);
}
}