fix(ui) Remove initial redirect logic from frontend (#8401)

This commit is contained in:
Chris Collins 2023-07-31 00:27:25 -04:00 committed by GitHub
parent dafb15071a
commit 564d8a3760
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 0 additions and 63 deletions

View File

@ -3,7 +3,6 @@ import { useGetMeLazyQuery } from '../../graphql/me.generated';
import { useGetGlobalViewsSettingsLazyQuery } from '../../graphql/app.generated';
import { CorpUser, PlatformPrivileges } from '../../types.generated';
import { UserContext, LocalState, DEFAULT_STATE, State } from './userContext';
import { useInitialRedirect } from './useInitialRedirect';
// TODO: Migrate all usage of useAuthenticatedUser to using this provider.
@ -125,11 +124,6 @@ const UserContextProvider = ({ children }: { children: React.ReactNode }) => {
}
}, [state, localState.selectedViewUrn, setDefaultSelectedView]);
/**
* Route to the most recently visited path once on first load of home page, if present in local storage.
*/
useInitialRedirect(state, localState, setState, updateLocalState);
return (
<UserContext.Provider
value={{

View File

@ -1,52 +0,0 @@
import { useEffect } from 'react';
import { useHistory, useLocation } from 'react-router';
import { PageRoutes } from '../../conf/Global';
export function useInitialRedirect(state, localState, setState, setLocalState) {
const location = useLocation();
const history = useHistory();
/**
* Route to the most recently visited path once on first load of home page, if present in local storage.
*/
useEffect(() => {
if (!state.loadedInitialPath) {
if (location.pathname === PageRoutes.ROOT && localState.selectedPath !== location.pathname) {
if (localState.selectedPath && !localState.selectedPath.includes(PageRoutes.EMBED)) {
history.replace({
pathname: localState.selectedPath,
search: localState.selectedSearch || '',
});
}
}
setState({
...state,
loadedInitialPath: true,
});
}
}, [
localState.selectedPath,
localState.selectedSearch,
location.pathname,
location.search,
state,
history,
setState,
]);
/**
* When the location of the browse changes, save the latest to local state.
*/
useEffect(() => {
if (
(localState.selectedPath !== location.pathname || localState.selectedSearch !== location.search) &&
!location.pathname.includes(PageRoutes.EMBED)
) {
setLocalState({
...localState,
selectedPath: location.pathname,
selectedSearch: location.search,
});
}
}, [location.pathname, location.search, localState, setLocalState]);
}

View File

@ -22,10 +22,6 @@ export type State = {
loadedPersonalDefaultViewUrn: boolean;
hasSetDefaultView: boolean;
};
/**
* Whether the initial page path has been loaded.
*/
loadedInitialPath: boolean;
};
/**
@ -54,7 +50,6 @@ export const DEFAULT_STATE: State = {
loadedPersonalDefaultViewUrn: false,
hasSetDefaultView: false,
},
loadedInitialPath: false,
};
export const DEFAULT_CONTEXT = {