Skip to content

Commit

Permalink
feat: loading screen for policy matching
Browse files Browse the repository at this point in the history
  • Loading branch information
xJonathanLEI committed Dec 17, 2024
1 parent 7b70092 commit 6e47dcb
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions packages/keychain/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,13 @@ import { Upgrade } from "components/connect/Upgrade";
import { PurchaseCredits } from "components/Funding/PurchaseCredits";
import { useEffect, useState } from "react";
import { usePostHog } from "posthog-js/react";
import { PageLoading } from "components/Loading";

function Home() {
const { context, controller, error, policies, upgrade } = useConnection();
const [hasSessionForPolicies, setHasSessionForPolicies] =
useState<boolean>(false);
const [hasSessionForPolicies, setHasSessionForPolicies] = useState<
boolean | undefined
>(undefined);
const posthog = usePostHog();

useEffect(() => {
Expand All @@ -41,7 +43,7 @@ function Home() {
setHasSessionForPolicies(!!session);
});
} else {
setHasSessionForPolicies(false);
setHasSessionForPolicies(undefined);
}
}, [controller, policies]);

Expand Down Expand Up @@ -85,7 +87,10 @@ function Home() {
return <></>;
}

if (hasSessionForPolicies) {
if (hasSessionForPolicies === undefined) {
// This is likely never observable in a real application but just in case.
return <PageLoading />;
} else if (hasSessionForPolicies) {
context.resolve({
code: ResponseCodes.SUCCESS,
address: controller.address,
Expand Down

0 comments on commit 6e47dcb

Please sign in to comment.