Skip to content

Commit

Permalink
fix: Add back in the "Reconnect to Server" dialogs
Browse files Browse the repository at this point in the history
  • Loading branch information
alexanderson1993 committed Feb 16, 2023
1 parent 2c562b8 commit 7f34e1c
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions client/src/context/AppContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,13 @@ import {getTabId} from "@thorium/tab-id";
import {
createLiveQueryReact,
LiveQueryProvider,
useLiveQuery,
} from "@thorium/live-query/client";
import {AppRouter} from "@server/init/router";
import {ThoriumAccountContextProvider} from "./ThoriumAccountContext";
import {useSessionStorage} from "@client/hooks/useSessionStorage";
import {randomFromList} from "@server/utils/randomFromList";
import {Disconnected, Reconnecting} from "./ConnectionStatus";

const Fallback: React.FC<FallbackProps> = ({error}) => {
return (
Expand Down Expand Up @@ -57,6 +59,14 @@ async function getRequestContext() {
return {id: await getTabId()};
}

function ConnectionStatus() {
const {reconnectionState} = useLiveQuery();

if (reconnectionState === "reconnecting") return <Reconnecting />;
if (reconnectionState === "disconnected") return <Disconnected />;
return null;
}

/**
* A component to contain all of the context and wrapper components for the app.
*/
Expand All @@ -68,6 +78,7 @@ export default function AppContext({children}: {children: ReactNode}) {
<ErrorBoundary FallbackComponent={Fallback}>
<Suspense fallback={<LoadingSpinner />}>
<LiveQueryProvider getRequestContext={getRequestContext}>
<ConnectionStatus />
<ErrorBoundary FallbackComponent={Fallback}>
<Suspense fallback={<LoadingSpinner />}>
<ThoriumAccountContextProvider>
Expand Down

0 comments on commit 7f34e1c

Please sign in to comment.