Spaces:
Configuration error
Configuration error
Download frontend/src/hooks/mutation/use-logout.ts from flyingdarkdev/README: direct link, hf CLI and curl.
- Browser
- Download file 912 Bytes
-
https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/frontend/src/hooks/mutation/use-logout.ts
- Command line
-
hf download hf://spaces/flyingdarkdev/README/frontend/src/hooks/mutation/use-logout.ts
-
curl -L -o use-logout.ts https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/frontend/src/hooks/mutation/use-logout.ts
912 Bytes
| import { useMutation, useQueryClient } from "@tanstack/react-query"; | |
| import OpenHands from "#/api/open-hands"; | |
| import { useAuth } from "#/context/auth-context"; | |
| import { useConfig } from "../query/use-config"; | |
| export const useLogout = () => { | |
| const { setGitHubTokenIsSet } = useAuth(); | |
| const queryClient = useQueryClient(); | |
| const { data: config } = useConfig(); | |
| return useMutation({ | |
| mutationFn: async () => { | |
| // Pause all queries that depend on githubTokenIsSet | |
| queryClient.setQueryData(["user"], null); | |
| // Call logout endpoint | |
| await OpenHands.logout(config?.APP_MODE ?? "oss"); | |
| // Remove settings from cache so it will be refetched with new token state | |
| queryClient.removeQueries({ queryKey: ["settings"] }); | |
| // Update token state - this will trigger a settings refetch since it's part of the query key | |
| setGitHubTokenIsSet(false); | |
| }, | |
| }); | |
| }; | |