File size: 780 Bytes
246d201 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
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;
};
|