Compare commits

...

6 Commits

Author SHA1 Message Date
amanape
bfbcdeb5eb Lint 2025-03-05 01:38:37 +04:00
amanape
936f7c75fd Better solution 2025-03-05 01:34:23 +04:00
amanape
41358adb82 logs 2025-03-05 01:01:34 +04:00
amanape
9edd0f843b Merge branch 'main' into fix/waitlist-modal 2025-03-05 00:59:02 +04:00
amanape
8fc7a46859 Fix type 2025-03-04 03:17:05 +04:00
amanape
a01b93f0dc Invalidate auth if cookie is not present 2025-03-04 03:10:45 +04:00
2 changed files with 14 additions and 6 deletions

View File

@@ -30,7 +30,6 @@ describe("Home Screen", () => {
const RouterStub = createRoutesStub([
{
// layout route
Component: MainApp,
path: "/",
children: [

View File

@@ -1,23 +1,32 @@
import { useQuery } from "@tanstack/react-query";
import { useQuery, useQueryClient } from "@tanstack/react-query";
import React from "react";
import OpenHands from "#/api/open-hands";
import { useConfig } from "./use-config";
import { useAuth } from "#/context/auth-context";
export const useIsAuthed = () => {
const { githubTokenIsSet } = useAuth();
const queryClient = useQueryClient();
const { githubTokenIsSet, setGitHubTokenIsSet } = useAuth();
const { data: config } = useConfig();
const appMode = React.useMemo(() => config?.APP_MODE, [config]);
const appMode = config?.APP_MODE;
return useQuery({
const query = useQuery({
queryKey: ["user", "authenticated", githubTokenIsSet, appMode],
queryFn: () => OpenHands.authenticate(appMode!),
enabled: !!appMode,
staleTime: 1000 * 60 * 5, // 5 minutes
retry: false,
meta: {
disableToast: true,
},
});
React.useEffect(() => {
if (query.isError) {
queryClient.invalidateQueries();
setGitHubTokenIsSet(false);
}
}, [query.isError]);
return query;
};