mirror of
https://github.com/docmost/docmost.git
synced 2026-05-07 22:53:08 +08:00
3430f715ec
Improves user experience by allowing users to return to the previous page after visiting the Settings section. Co-authored-by: Philipinho <16838612+Philipinho@users.noreply.github.com>
16 lines
537 B
TypeScript
16 lines
537 B
TypeScript
import { settingsOriginAtom } from "@/components/settings/atoms/settings-origin-atom";
|
|
import { useAtomValue, useSetAtom } from "jotai";
|
|
import { useEffect } from "react";
|
|
import { useLocation } from "react-router-dom";
|
|
|
|
export function useTrackOrigin() {
|
|
const location = useLocation();
|
|
const setOrigin = useSetAtom(settingsOriginAtom);
|
|
|
|
useEffect(() => {
|
|
const isInSettings = location.pathname.startsWith("/settings");
|
|
if (!isInSettings) {
|
|
setOrigin(location.pathname);
|
|
}
|
|
}, [location.pathname, setOrigin]);
|
|
} |