-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Save the last visited path for the Accounts pages #62344
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
mountiny
merged 3 commits into
Expensify:main
from
software-mansion-labs:borys3kk-navigation-accounts-tab-not-saved
May 21, 2025
+140
−73
Merged
Changes from 1 commit
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
22 changes: 0 additions & 22 deletions
22
src/libs/Navigation/helpers/getLastVisitedWorkspaceTabScreen/index.native.ts
This file was deleted.
Oops, something went wrong.
41 changes: 0 additions & 41 deletions
41
src/libs/Navigation/helpers/getLastVisitedWorkspaceTabScreen/index.ts
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/libs/Navigation/helpers/lastVisitedTabPathUtils/index.native.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import type {NavigationState, PartialState} from '@react-navigation/native'; | ||
import type {Route} from '@src/ROUTES'; | ||
|
||
function clearSessionStorage() {} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
function saveWorkspacesTabPathToSessionStorage(url: string) {} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
function saveSettingsTabPathToSessionStorage(url: string) {} | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unused-vars | ||
function getLastVisitedTabPath(state: NavigationState | PartialState<NavigationState>): Route | undefined { | ||
return undefined; | ||
} | ||
|
||
function getWorkspacesTabStateFromSessionStorage() { | ||
return undefined; | ||
} | ||
function getSettingsTabStateFromSessionStorage() { | ||
return undefined; | ||
} | ||
|
||
function getLastVisitedWorkspaceTabScreen() { | ||
return undefined; | ||
} | ||
|
||
export { | ||
clearSessionStorage, | ||
getLastVisitedWorkspaceTabScreen, | ||
getLastVisitedTabPath, | ||
saveSettingsTabPathToSessionStorage, | ||
getSettingsTabStateFromSessionStorage, | ||
saveWorkspacesTabPathToSessionStorage, | ||
getWorkspacesTabStateFromSessionStorage, | ||
}; |
71 changes: 71 additions & 0 deletions
71
src/libs/Navigation/helpers/lastVisitedTabPathUtils/index.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
import type {NavigationState, PartialState} from '@react-navigation/native'; | ||
import {findFocusedRoute} from '@react-navigation/native'; | ||
import type {ValueOf} from 'type-fest'; | ||
import getStateFromPath from '@libs/Navigation/helpers/getStateFromPath'; | ||
import CONST from '@src/CONST'; | ||
import type {Route} from '@src/ROUTES'; | ||
|
||
type SessionStorageKey = ValueOf<typeof CONST.SESSION_STORAGE_KEYS.LAST_VISITED_TAB_PATH>; | ||
|
||
/** | ||
* Clears all session storage data. | ||
*/ | ||
function clearSessionStorage() { | ||
sessionStorage.clear(); | ||
} | ||
|
||
/** | ||
* Generic function to save a path to session storage by key | ||
*/ | ||
function saveTabPathToSessionStorage(key: SessionStorageKey, url: string) { | ||
sessionStorage.setItem(key, url); | ||
} | ||
|
||
/** | ||
* Converts stored path to navigation state | ||
*/ | ||
function getTabStateFromSessionStorage(key: SessionStorageKey) { | ||
const path = sessionStorage.getItem(key) as Route | undefined; | ||
if (!path) { | ||
return undefined; | ||
} | ||
return getStateFromPath(path); | ||
} | ||
|
||
/** | ||
* Generic function to extract the path from currently focused route | ||
*/ | ||
function getLastVisitedTabPath(state: NavigationState | PartialState<NavigationState>): Route | undefined { | ||
return findFocusedRoute(state)?.path as Route | undefined; | ||
} | ||
|
||
function saveWorkspacesTabPathToSessionStorage(url: string) { | ||
saveTabPathToSessionStorage(CONST.SESSION_STORAGE_KEYS.LAST_VISITED_TAB_PATH.WORKSPACES, url); | ||
} | ||
|
||
function getWorkspacesTabStateFromSessionStorage() { | ||
return getTabStateFromSessionStorage(CONST.SESSION_STORAGE_KEYS.LAST_VISITED_TAB_PATH.WORKSPACES); | ||
} | ||
|
||
function saveSettingsTabPathToSessionStorage(url: string) { | ||
saveTabPathToSessionStorage(CONST.SESSION_STORAGE_KEYS.LAST_VISITED_TAB_PATH.SETTINGS, url); | ||
} | ||
|
||
function getSettingsTabStateFromSessionStorage() { | ||
return getTabStateFromSessionStorage(CONST.SESSION_STORAGE_KEYS.LAST_VISITED_TAB_PATH.SETTINGS); | ||
} | ||
|
||
function getLastVisitedWorkspaceTabScreen() { | ||
const workspacesTabState = getWorkspacesTabStateFromSessionStorage(); | ||
return workspacesTabState?.routes?.at(-1)?.state?.routes?.at(-1)?.name; | ||
} | ||
|
||
export { | ||
clearSessionStorage, | ||
getLastVisitedWorkspaceTabScreen, | ||
getLastVisitedTabPath, | ||
saveSettingsTabPathToSessionStorage, | ||
getSettingsTabStateFromSessionStorage, | ||
saveWorkspacesTabPathToSessionStorage, | ||
getWorkspacesTabStateFromSessionStorage, | ||
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.