Skip to content

Commit

Permalink
preserve navigation state
Browse files Browse the repository at this point in the history
  • Loading branch information
ehconitin committed Aug 18, 2024
1 parent 1679dac commit 841dbb4
Showing 1 changed file with 15 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useCallback, useEffect } from 'react';
import { useNavigate } from 'react-router-dom';
import { useLocation, useNavigate } from 'react-router-dom';
import { useRecoilValue, useSetRecoilState } from 'recoil';

import { useObjectMetadataItem } from '@/object-metadata/hooks/useObjectMetadataItem';
Expand All @@ -11,6 +11,7 @@ import { recordIndexFieldDefinitionsState } from '@/object-record/record-index/s
import { recordIndexIsCompactModeActiveState } from '@/object-record/record-index/states/recordIndexIsCompactModeActiveState';
import { recordIndexKanbanFieldMetadataIdState } from '@/object-record/record-index/states/recordIndexKanbanFieldMetadataIdState';
import { computeRecordBoardColumnDefinitionsFromObjectMetadata } from '@/object-record/utils/computeRecordBoardColumnDefinitionsFromObjectMetadata';
import { navigationMemorizedUrlState } from '@/ui/navigation/states/navigationMemorizedUrlState';
import { FieldMetadataType } from '~/generated-metadata/graphql';
import { isDefined } from '~/utils/isDefined';

Expand Down Expand Up @@ -60,10 +61,21 @@ export const RecordIndexBoardDataLoaderEffect = ({
}, [recordIndexFieldDefinitions, setFieldDefinitions]);

const navigate = useNavigate();
const location = useLocation();
const setNavigationMemorizedUrl = useSetRecoilState(
navigationMemorizedUrlState,
);

const navigateToSelectSettings = useCallback(() => {
console.log('hehe');
setNavigationMemorizedUrl(location.pathname + location.search);
navigate(`/settings/objects/${getObjectSlug(objectMetadataItem)}`);
}, [navigate, objectMetadataItem]);
}, [
navigate,
objectMetadataItem,
location.pathname,
location.search,
setNavigationMemorizedUrl,
]);

const { resetRecordSelection } = useRecordBoardSelection(recordBoardId);

Expand All @@ -81,7 +93,6 @@ export const RecordIndexBoardDataLoaderEffect = ({
);
}, [
navigateToSelectSettings,

objectMetadataItem,
objectNameSingular,
recordIndexKanbanFieldMetadataId,
Expand Down

0 comments on commit 841dbb4

Please sign in to comment.