fix: login redirection to active objects (#15366)

Fixes - https://github.com/twentyhq/twenty/issues/15364

- Removed `activeNonSystemObjectMetadataItems` from the hook as it was
not necessary. Hook use `alphaSortedActiveNonSystemObjectMetadataItems`
now.
- Correctly check for read permissions.

---------

Co-authored-by: Charles Bochet <charles@twenty.com>
This commit is contained in:
Ranjeet Baraik
2025-10-30 22:01:26 +05:30
committed by GitHub
parent 51fdaf2731
commit 0cbd1e8ec5
12 changed files with 87 additions and 55 deletions
@@ -12,6 +12,7 @@ import {
useEventTracker,
} from '@/analytics/hooks/useEventTracker';
import { useExecuteTasksOnAnyLocationChange } from '@/app/hooks/useExecuteTasksOnAnyLocationChange';
import { isAppEffectRedirectEnabledState } from '@/app/states/isAppEffectRedirectEnabledState';
import { useRequestFreshCaptchaToken } from '@/captcha/hooks/useRequestFreshCaptchaToken';
import { isCaptchaScriptLoadedState } from '@/captcha/states/isCaptchaScriptLoadedState';
import { isCaptchaRequiredForPath } from '@/captcha/utils/isCaptchaRequiredForPath';
@@ -88,6 +89,10 @@ export const PageChangeEffect = () => {
const { executeTasksOnAnyLocationChange } =
useExecuteTasksOnAnyLocationChange();
const isAppEffectRedirectEnabled = useRecoilValue(
isAppEffectRedirectEnabledState,
);
const { closeCommandMenu } = useCommandMenu();
const { resetFocusStackToFocusItem } = useResetFocusStackToFocusItem();
@@ -110,10 +115,18 @@ export const PageChangeEffect = () => {
useEffect(() => {
initializeQueryParamState();
if (isDefined(pageChangeEffectNavigateLocation)) {
if (
isDefined(pageChangeEffectNavigateLocation) &&
isAppEffectRedirectEnabled
) {
navigate(pageChangeEffectNavigateLocation);
}
}, [navigate, pageChangeEffectNavigateLocation, initializeQueryParamState]);
}, [
navigate,
pageChangeEffectNavigateLocation,
initializeQueryParamState,
isAppEffectRedirectEnabled,
]);
useEffect(() => {
const isLeavingRecordIndexPage = !!matchPath(