Spaces:
Configuration error
Configuration error
Download frontend/src/hooks/use-end-session.ts from flyingdarkdev/README: direct link, hf CLI and curl.
- Browser
- Download file 752 Bytes
-
https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/frontend/src/hooks/use-end-session.ts
- Command line
-
hf download hf://spaces/flyingdarkdev/README/frontend/src/hooks/use-end-session.ts
-
curl -L -o use-end-session.ts https://huggingface.co/spaces/flyingdarkdev/README/resolve/main/frontend/src/hooks/use-end-session.ts
752 Bytes
| import { useDispatch } from "react-redux"; | |
| import { useNavigate } from "react-router"; | |
| import { | |
| initialState as browserInitialState, | |
| setScreenshotSrc, | |
| setUrl, | |
| } from "#/state/browser-slice"; | |
| import { clearSelectedRepository } from "#/state/initial-query-slice"; | |
| export const useEndSession = () => { | |
| const navigate = useNavigate(); | |
| const dispatch = useDispatch(); | |
| /** | |
| * End the current session by clearing the token and redirecting to the home page. | |
| */ | |
| const endSession = () => { | |
| dispatch(clearSelectedRepository()); | |
| // Reset browser state to initial values | |
| dispatch(setUrl(browserInitialState.url)); | |
| dispatch(setScreenshotSrc(browserInitialState.screenshotSrc)); | |
| navigate("/"); | |
| }; | |
| return endSession; | |
| }; | |