Skip to content

Commit

Permalink
Debug
Browse files Browse the repository at this point in the history
  • Loading branch information
atrincas committed Dec 31, 2024
1 parent d195c42 commit 742ff52
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions client/src/components/session-checker/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useEffect } from "react";
import { useEffect, useMemo } from "react";

import { usePathname } from "next/navigation";

Expand All @@ -18,6 +18,14 @@ import { isPrivatePath } from "@/lib/utils";
export default function SessionChecker() {
const { data: session } = useSession();
const queryKey = queryKeys.auth.validateToken(session?.accessToken).queryKey;

const pathname = usePathname();
const queryEnabled = useMemo(
() => isPrivatePath(pathname) && !!session?.accessToken,
[session?.accessToken, pathname],
);
console.info("queryEnabled", queryEnabled);
console.info("session", session);
const { error } = client.auth.validateToken.useQuery(
queryKey,
{
Expand All @@ -30,10 +38,10 @@ export default function SessionChecker() {
},
{
queryKey,
enabled: !!session?.accessToken,
enabled: queryEnabled,
},
);
const pathname = usePathname();
console.info("error", error);

useEffect(() => {
if (error && isPrivatePath(pathname)) {
Expand Down

0 comments on commit 742ff52

Please sign in to comment.