diff --git a/packages/twenty-front/src/modules/navigation/hooks/useLastVisitedPageOrView.ts b/packages/twenty-front/src/modules/navigation/hooks/useLastVisitedPageOrView.ts index 6a762c1475ca..10a5c4187620 100644 --- a/packages/twenty-front/src/modules/navigation/hooks/useLastVisitedPageOrView.ts +++ b/packages/twenty-front/src/modules/navigation/hooks/useLastVisitedPageOrView.ts @@ -52,19 +52,16 @@ export const useLastVisitedPageOrView = () => { } }; - const setLastVisitedObjectOrView = ( - { - objectMetadataId, - viewId, - }: { - objectMetadataId: string; - viewId: string; - }, - isSlug = false, - ) => { - const fallbackObjectMetadataId = isSlug - ? (findActiveObjectMetadataItemBySlug(objectMetadataId)?.id ?? '') - : objectMetadataId; + const setLastVisitedObjectOrView = ({ + componentId, + viewId, + }: { + componentId: string; + viewId: string; + }) => { + const fallbackObjectMetadataId = + findActiveObjectMetadataItemBySlug(componentId)?.id ?? ''; + const fallbackViewId = lastVisitedObjectMetadataId === fallbackObjectMetadataId ? viewId diff --git a/packages/twenty-front/src/modules/object-metadata/utils/getObjectMetadataAndViewIdFromPath.ts b/packages/twenty-front/src/modules/object-metadata/utils/getObjectMetadataAndViewIdFromPath.ts index 87dcff155e66..497fda2e539f 100644 --- a/packages/twenty-front/src/modules/object-metadata/utils/getObjectMetadataAndViewIdFromPath.ts +++ b/packages/twenty-front/src/modules/object-metadata/utils/getObjectMetadataAndViewIdFromPath.ts @@ -8,7 +8,7 @@ export const getObjectAndViewIdFromPath = (path: string) => { } return { - objectMetadataId: result[1], + componentId: result[1], viewId: result[2], }; }; diff --git a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerItem.tsx b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerItem.tsx index 68ad1127ea6a..37b31b47db17 100644 --- a/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerItem.tsx +++ b/packages/twenty-front/src/modules/ui/navigation/navigation-drawer/components/NavigationDrawerItem.tsx @@ -153,14 +153,11 @@ export const NavigationDrawerItem = ({ if (isNonEmptyString(to)) { const objectAndViewId = getObjectAndViewIdFromPath(to); if (!isEmptyObject(objectAndViewId)) { - const { objectMetadataId, viewId } = objectAndViewId; - setLastVisitedObjectOrView( - { - objectMetadataId, - viewId, - }, - true, - ); + const { componentId, viewId } = objectAndViewId; + setLastVisitedObjectOrView({ + componentId, + viewId, + }); } navigate(to); } diff --git a/packages/twenty-front/src/modules/views/view-picker/components/ViewPickerListContent.tsx b/packages/twenty-front/src/modules/views/view-picker/components/ViewPickerListContent.tsx index 302c84a19fba..10bf87f67891 100644 --- a/packages/twenty-front/src/modules/views/view-picker/components/ViewPickerListContent.tsx +++ b/packages/twenty-front/src/modules/views/view-picker/components/ViewPickerListContent.tsx @@ -44,13 +44,10 @@ export const ViewPickerListContent = () => { const { setLastVisitedObjectOrView } = useLastVisitedPageOrView(); const handleViewSelect = (viewId: string) => { - setLastVisitedObjectOrView( - { - objectMetadataId: componentId, - viewId, - }, - true, - ); + setLastVisitedObjectOrView({ + componentId, + viewId, + }); selectView(viewId); closeDropdown(); }; diff --git a/packages/twenty-front/src/modules/views/view-picker/hooks/useViewPickerPersistView.ts b/packages/twenty-front/src/modules/views/view-picker/hooks/useViewPickerPersistView.ts index cf9c65bd43c8..6a191032a5b9 100644 --- a/packages/twenty-front/src/modules/views/view-picker/hooks/useViewPickerPersistView.ts +++ b/packages/twenty-front/src/modules/views/view-picker/hooks/useViewPickerPersistView.ts @@ -48,13 +48,10 @@ export const useViewPickerPersistView = () => { }); closeAndResetViewPicker(); selectView(id); - setLastVisitedObjectOrView( - { - objectMetadataId: componentId, - viewId: id, - }, - true, - ); + setLastVisitedObjectOrView({ + componentId, + viewId: id, + }); }, [ closeAndResetViewPicker, @@ -93,13 +90,10 @@ export const useViewPickerPersistView = () => { viewA.key === 'INDEX' ? -1 : viewA.position - viewB.position, ) .filter((view) => view.id !== viewPickerReferenceViewId); - setLastVisitedObjectOrView( - { - objectMetadataId: componentId, - viewId: indexOrFirstView.id, - }, - true, - ); + setLastVisitedObjectOrView({ + componentId, + viewId: indexOrFirstView.id, + }); }, [ closeAndResetViewPicker,