mirror of
https://github.com/cheeaun/phanpy.git
synced 2025-03-22 21:59:22 +01:00
Slight rewrite, possibly breaking
This commit is contained in:
parent
f2c2983663
commit
8bf3f31056
1 changed files with 8 additions and 4 deletions
12
src/app.jsx
12
src/app.jsx
|
@ -267,11 +267,14 @@ function PrimaryRoutes({ isLoggedIn, loading }) {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function getPrevLocation() {
|
||||||
|
return states.prevLocation || null;
|
||||||
|
}
|
||||||
function SecondaryRoutes({ isLoggedIn }) {
|
function SecondaryRoutes({ isLoggedIn }) {
|
||||||
const snapStates = useSnapshot(states);
|
// const snapStates = useSnapshot(states);
|
||||||
const location = useLocation();
|
const location = useLocation();
|
||||||
const prevLocation = snapStates.prevLocation;
|
// const prevLocation = snapStates.prevLocation;
|
||||||
const backgroundLocation = useRef(prevLocation || null);
|
const backgroundLocation = useRef(getPrevLocation());
|
||||||
|
|
||||||
const isModalPage = useMemo(() => {
|
const isModalPage = useMemo(() => {
|
||||||
return (
|
return (
|
||||||
|
@ -280,7 +283,8 @@ function SecondaryRoutes({ isLoggedIn }) {
|
||||||
);
|
);
|
||||||
}, [location.pathname, matchPath]);
|
}, [location.pathname, matchPath]);
|
||||||
if (isModalPage) {
|
if (isModalPage) {
|
||||||
if (!backgroundLocation.current) backgroundLocation.current = prevLocation;
|
if (!backgroundLocation.current)
|
||||||
|
backgroundLocation.current = getPrevLocation();
|
||||||
} else {
|
} else {
|
||||||
backgroundLocation.current = null;
|
backgroundLocation.current = null;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue