Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type {NavigationState, ParamListBase, RouteProp, StackNavigationState} from '@react-navigation/native';
import {useEffect} from 'react';
import NAVIGATORS from '@src/NAVIGATORS';

const preservedNavigatorStates: Record<string, StackNavigationState<ParamListBase>> = {};

Expand All @@ -13,6 +14,14 @@ const cleanPreservedNavigatorStates = (state: NavigationState) => {
}
};

const clearPreservedSearchNavigatorStates = () => {
for (const key of Object.keys(preservedNavigatorStates)) {
if (key.startsWith(NAVIGATORS.SEARCH_FULLSCREEN_NAVIGATOR)) {
delete preservedNavigatorStates[key];
}
}
};

const getPreservedNavigatorState = (key: string) => preservedNavigatorStates[key];

function usePreserveNavigatorState(state: StackNavigationState<ParamListBase>, route: RouteProp<ParamListBase> | undefined) {
Expand All @@ -26,4 +35,4 @@ function usePreserveNavigatorState(state: StackNavigationState<ParamListBase>, r

export default usePreserveNavigatorState;

export {getPreservedNavigatorState, cleanPreservedNavigatorStates};
export {getPreservedNavigatorState, cleanPreservedNavigatorStates, clearPreservedSearchNavigatorStates};
4 changes: 4 additions & 0 deletions src/libs/actions/Delegate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import type {AddDelegateParams as APIAddDelegateParams, RemoveDelegateParams as
import {READ_COMMANDS, SIDE_EFFECT_REQUEST_COMMANDS, WRITE_COMMANDS} from '@libs/API/types';
import * as ErrorUtils from '@libs/ErrorUtils';
import Log from '@libs/Log';
import {clearPreservedSearchNavigatorStates} from '@libs/Navigation/AppNavigator/createSplitNavigator/usePreserveNavigatorState';
import * as NetworkStore from '@libs/Network/NetworkStore';
import * as SequentialQueue from '@libs/Network/SequentialQueue';
import CONFIG from '@src/CONFIG';
Expand Down Expand Up @@ -187,6 +188,7 @@ function connect({email, delegatedAccess, credentials, session, activePolicyID,
Onyx.update(failureData);
return;
}
clearPreservedSearchNavigatorStates();
const restrictedToken = response.restrictedToken;
const policyID = activePolicyID;

Expand Down Expand Up @@ -272,6 +274,8 @@ function disconnect({stashedCredentials, stashedSession}: DisconnectParams) {
return;
}

clearPreservedSearchNavigatorStates();

const requesterEmail = response.requesterEmail;
const authToken = response.authToken;
return SequentialQueue.waitForIdle()
Expand Down
Loading