diff --git a/src/libs/API/index.ts b/src/libs/API/index.ts index 089c1452ccb46..3dcdfe3ad4d37 100644 --- a/src/libs/API/index.ts +++ b/src/libs/API/index.ts @@ -5,6 +5,7 @@ import {resolveDuplicationConflictAction, resolveEnableFeatureConflicts} from '@ import type {EnablePolicyFeatureCommand, RequestMatcher} from '@libs/actions/RequestConflictUtils'; import Log from '@libs/Log'; import {handleDeletedAccount, HandleUnusedOptimisticID, Logging, Pagination, Reauthentication, RecheckConnection, SaveResponseInOnyx} from '@libs/Middleware'; +import {saveWorkspacesTabPathToSessionStorage} from '@libs/Navigation/helpers/lastVisitedTabPathUtils'; import {isOffline} from '@libs/Network/NetworkStore'; import {push as pushToSequentialQueue, waitForIdle as waitForSequentialQueueIdle} from '@libs/Network/SequentialQueue'; import Pusher from '@libs/Pusher'; @@ -15,7 +16,7 @@ import type OnyxRequest from '@src/types/onyx/Request'; import type {PaginatedRequest, PaginationConfig, RequestConflictResolver} from '@src/types/onyx/Request'; import type Response from '@src/types/onyx/Response'; import type {ApiCommand, ApiRequestCommandParameters, ApiRequestType, CommandOfType, ReadCommand, SideEffectRequestCommand, WriteCommand} from './types'; -import {READ_COMMANDS} from './types'; +import {READ_COMMANDS, SIDE_EFFECT_REQUEST_COMMANDS} from './types'; // Setup API middlewares. Each request made will pass through a series of middleware functions that will get called in sequence (each one passing the result of the previous to the next). // Note: The ordering here is intentional as we want to Log, Recheck Connection, Reauthenticate, and Save the Response in Onyx. Errors thrown in one middleware will bubble to the next. @@ -196,6 +197,9 @@ function makeRequestWithSideEffects( onyxData: OnyxData = {}, ): Promise { Log.info('[API] Called API makeRequestWithSideEffects', false, {command, ...apiCommandParameters}); + if (command === SIDE_EFFECT_REQUEST_COMMANDS.DISCONNECT_AS_DELEGATE || command === SIDE_EFFECT_REQUEST_COMMANDS.CONNECT_AS_DELEGATE) { + saveWorkspacesTabPathToSessionStorage('/settings/workspaces'); + } const request = prepareRequest(command, CONST.API_REQUEST_TYPE.MAKE_REQUEST_WITH_SIDE_EFFECTS, apiCommandParameters, onyxData); // Return a promise containing the response from HTTPS