Clear stale parent-view filters on front-component cross-object navigation (#21869)
This commit is contained in:
+26
-1
@@ -6,12 +6,14 @@ import {
|
||||
type FrontComponentExecutionContext,
|
||||
type FrontComponentHostCommunicationApi,
|
||||
} from 'twenty-front-component-renderer';
|
||||
import { type AppPath, type EnqueueSnackbarParams } from 'twenty-shared/types';
|
||||
import { AppPath, type EnqueueSnackbarParams } from 'twenty-shared/types';
|
||||
|
||||
import { currentUserState } from '@/auth/states/currentUserState';
|
||||
import { useCommandMenuConfirmationModal } from '@/command-menu-item/confirmation-modal/hooks/useCommandMenuConfirmationModal';
|
||||
import { useUnmountCommand } from '@/command-menu-item/engine-command/hooks/useUnmountEngineCommand';
|
||||
import { commandMenuItemProgressFamilyState } from '@/command-menu-item/states/commandMenuItemProgressFamilyState';
|
||||
import { MAIN_CONTEXT_STORE_INSTANCE_ID } from '@/context-store/constants/MainContextStoreInstanceId';
|
||||
import { contextStoreRecordShowParentViewComponentState } from '@/context-store/states/contextStoreRecordShowParentViewComponentState';
|
||||
import { useRequestApplicationTokenRefresh } from '@/front-components/hooks/useRequestApplicationTokenRefresh';
|
||||
import { useNavigateSidePanel } from '@/side-panel/hooks/useNavigateSidePanel';
|
||||
import { useSidePanelMenu } from '@/side-panel/hooks/useSidePanelMenu';
|
||||
@@ -19,6 +21,7 @@ import { sidePanelSearchState } from '@/side-panel/states/sidePanelSearchState';
|
||||
import { useSnackBar } from '@/ui/feedback/snack-bar-manager/hooks/useSnackBar';
|
||||
import { useAtomStateValue } from '@/ui/utilities/state/jotai/hooks/useAtomStateValue';
|
||||
import { useSetAtomFamilyState } from '@/ui/utilities/state/jotai/hooks/useSetAtomFamilyState';
|
||||
import { useStore } from 'jotai';
|
||||
import { assertUnreachable, isDefined } from 'twenty-shared/utils';
|
||||
import { useIcons } from 'twenty-ui/icon';
|
||||
import { useCopyToClipboard } from '~/hooks/useCopyToClipboard';
|
||||
@@ -44,6 +47,7 @@ export const useFrontComponentExecutionContext = ({
|
||||
} => {
|
||||
const currentUser = useAtomStateValue(currentUserState);
|
||||
const navigateApp = useNavigateApp();
|
||||
const store = useStore();
|
||||
const { requestAccessTokenRefresh } = useRequestApplicationTokenRefresh({
|
||||
frontComponentId,
|
||||
});
|
||||
@@ -74,6 +78,27 @@ export const useFrontComponentExecutionContext = ({
|
||||
queryParams,
|
||||
options,
|
||||
) => {
|
||||
if (to === AppPath.RecordShowPage) {
|
||||
const targetObjectNameSingular = (
|
||||
params as { objectNameSingular?: string | null } | undefined
|
||||
)?.objectNameSingular;
|
||||
|
||||
const parentViewAtom =
|
||||
contextStoreRecordShowParentViewComponentState.atomFamily({
|
||||
instanceId: MAIN_CONTEXT_STORE_INSTANCE_ID,
|
||||
});
|
||||
|
||||
const parentView = store.get(parentViewAtom);
|
||||
|
||||
if (
|
||||
isDefined(parentView) &&
|
||||
isDefined(targetObjectNameSingular) &&
|
||||
parentView.parentViewObjectNameSingular !== targetObjectNameSingular
|
||||
) {
|
||||
store.set(parentViewAtom, undefined);
|
||||
}
|
||||
}
|
||||
|
||||
navigateApp(
|
||||
to as AppPath,
|
||||
params as Parameters<typeof navigateApp>[1],
|
||||
|
||||
Reference in New Issue
Block a user