Skip to content

Commit

Permalink
Add updateLastVisitedPath action
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuuszzzzz committed Dec 21, 2023
1 parent 96a2875 commit 837b26c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ONYXKEYS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ const ONYXKEYS = {
// Max width supported for HTML <canvas> element
MAX_CANVAS_WIDTH: 'maxCanvasWidth',

// Stores last visited path
LAST_VISITED_PATH: 'lastVisitedPath',

/** Collection Keys */
COLLECTION: {
DOWNLOAD: 'download_',
Expand Down Expand Up @@ -433,6 +436,7 @@ type OnyxValues = {
[ONYXKEYS.MAX_CANVAS_AREA]: number;
[ONYXKEYS.MAX_CANVAS_HEIGHT]: number;
[ONYXKEYS.MAX_CANVAS_WIDTH]: number;
[ONYXKEYS.LAST_VISITED_PATH]: string;

// Collections
[ONYXKEYS.COLLECTION.DOWNLOAD]: OnyxTypes.Download;
Expand Down
2 changes: 2 additions & 0 deletions src/libs/Navigation/NavigationRoot.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import useFlipper from '@hooks/useFlipper';
import useTheme from '@hooks/useTheme';
import useWindowDimensions from '@hooks/useWindowDimensions';
import Log from '@libs/Log';
import { updateLastVisitedPath } from '@userActions/App';
import AppNavigator from './AppNavigator';
import linkingConfig from './linkingConfig';
import Navigation, {navigationRef} from './Navigation';
Expand All @@ -26,6 +27,7 @@ function parseAndLogRoute(state: NavigationState) {
}

const currentPath = getPathFromState(state, linkingConfig.config);
updateLastVisitedPath(currentPath)

// Don't log the route transitions from OldDot because they contain authTokens
if (currentPath.includes('/transition')) {
Expand Down
5 changes: 5 additions & 0 deletions src/libs/actions/App.ts
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,10 @@ function handleRestrictedEvent(eventName: string) {
API.write('HandleRestrictedEvent', parameters);
}

function updateLastVisitedPath(path: string) {
Onyx.set(ONYXKEYS.LAST_VISITED_PATH, path)
}

export {
setLocale,
setLocaleAndNavigate,
Expand All @@ -553,4 +557,5 @@ export {
finalReconnectAppAfterActivatingReliableUpdates,
savePolicyDraftByNewWorkspace,
createWorkspaceWithPolicyDraftAndNavigateToIt,
updateLastVisitedPath,
};

0 comments on commit 837b26c

Please sign in to comment.