@@ -14,6 +14,7 @@ import {
1414 useSelector ,
1515 useLocationPath ,
1616 useGetSearchParam ,
17+ useDispatch
1718} from '../ui/hooks' ;
1819
1920import { sessionSelectors } from '../redux/selectors/session' ;
@@ -26,17 +27,28 @@ import { WaitToEnter } from '../ui/components';
2627
2728import { isRouteFound } from './utils/isRouteFound' ;
2829import { NotFound } from '../ui/layouts/NotFound' ;
30+ import { userSelectors } from '../redux/selectors' ;
31+ import {
32+ userActions ,
33+ } from '../redux/actions' ;
34+
2935
3036const useReplaceRouteIfNeeded = ( {
3137 currentLocation,
3238 setNotFound,
3339} : any ) : void => {
3440 const { replaceRoute } = useReplaceRoute ( ) ;
3541
42+ const user = useSelector ( userSelectors . myUser ) ;
3643 const routeFromSearchParam = useGetSearchParam ( 'route' ) ;
3744
3845 const isAuthenticated = useSelector ( sessionSelectors . authenticationToken ) ;
3946
47+ // const dispatch = useDispatch();
48+ // React.useEffect(() => {
49+ // dispatch(userActions.getMy({}));
50+ // }, [dispatch, userActions, isAuthenticated])
51+
4052 React . useEffect ( ( ) => {
4153 setNotFound (
4254 isRouteFound ( {
@@ -47,12 +59,13 @@ const useReplaceRouteIfNeeded = ({
4759
4860 React . useEffect ( ( ) => {
4961 replaceRouteIfNeeded ( {
62+ user,
5063 currentLocation,
5164 isAuthenticated,
5265 replaceRoute,
5366 routeFromSearchParam,
5467 } ) ;
55- } , [ currentLocation , isAuthenticated , replaceRoute ] ) ;
68+ } , [ user , currentLocation , isAuthenticated , replaceRoute ] ) ;
5669} ;
5770
5871export const AppRoute = ( { path, component, exact } : any ) : JSX . Element => {
0 commit comments