deadhead-space-freight-tycoon/apps/web/src/layout/lastScreen.ts

18 lines
496 B
TypeScript

import { useEffect } from "react";
import { useLocation } from "react-router";
let lastScreen = "/";
/** Records the screen the player is on, ignoring Settings itself (for debug info, CR-011). */
export function useTrackScreen(): void {
const { pathname } = useLocation();
useEffect(() => {
if (pathname !== "/settings") lastScreen = pathname;
}, [pathname]);
}
/** The last screen before Settings, e.g. "/fleet". */
export function lastScreenPath(): string {
return lastScreen;
}