@@ -4,7 +4,6 @@ import type {OnyxEntry, OnyxKey, OnyxUpdate} from 'react-native-onyx';
44import * as API from '@libs/API' ;
55import type { AddDelegateParams as APIAddDelegateParams , RemoveDelegateParams as APIRemoveDelegateParams , UpdateDelegateRoleParams as APIUpdateDelegateRoleParams } from '@libs/API/parameters' ;
66import { READ_COMMANDS , SIDE_EFFECT_REQUEST_COMMANDS , WRITE_COMMANDS } from '@libs/API/types' ;
7- import DateUtils from '@libs/DateUtils' ;
87import * as ErrorUtils from '@libs/ErrorUtils' ;
98import Log from '@libs/Log' ;
109import { clearPreservedSearchNavigatorStates } from '@libs/Navigation/AppNavigator/createSplitNavigator/usePreserveNavigatorState' ;
@@ -18,6 +17,7 @@ import type Credentials from '@src/types/onyx/Credentials';
1817import type Response from '@src/types/onyx/Response' ;
1918import type Session from '@src/types/onyx/Session' ;
2019import { confirmReadyToOpenApp , openApp } from './App' ;
20+ import clearOnyxAndSeedFullReconnect from './clearOnyxAndSeedFullReconnect' ;
2121import updateSessionAuthTokens from './Session/updateSessionAuthTokens' ;
2222import updateSessionUser from './Session/updateSessionUser' ;
2323
@@ -43,25 +43,17 @@ const KEYS_TO_PRESERVE_DELEGATE_ACCESS = [
4343] ;
4444
4545/**
46- * Atomically reset Onyx for a delegate-access transition while seeding two values that
47- * subscribers would otherwise misinterpret on the post-clear state and double up calls
48- * the caller is about to make explicitly:
46+ * Atomically reset Onyx for a delegate-access transition. The IS_LOADING_APP=true
47+ * seed is delegate-specific: without it, consumers observe HAS_LOADED_APP=true and
48+ * IS_LOADING_APP=undefined together, which looks like a stuck app and triggers
49+ * DelegateAccessHandler's recovery effect, queueing a duplicate openApp.
4950 *
50- * - IS_LOADING_APP=true: without it, consumers observe HAS_LOADED_APP=true and
51- * IS_LOADING_APP=undefined together, which looks like a stuck app and triggers
52- * DelegateAccessHandler's recovery effect, queueing a duplicate openApp.
53- * - LAST_FULL_RECONNECT_TIME=now: subscribeToFullReconnect compares this against the
54- * server-supplied NVP_RECONNECT_APP_IF_FULL_RECONNECT_BEFORE that lands in OpenApp's
55- * response.onyxData. Because applyHTTPSOnyxUpdates applies response.onyxData before
56- * successData, the timestamp would still be empty when the comparison runs, falsely
57- * triggering a duplicate ReconnectApp. Seeding to `now` short-circuits the subscriber
58- * until OpenApp's successData refreshes it.
51+ * The reconnect-time seed is handled by clearOnyxAndSeedFullReconnect.
5952 */
6053function clearOnyxForDelegateTransition ( ) : Promise < void > {
61- return Onyx . multiSet ( {
54+ return clearOnyxAndSeedFullReconnect ( KEYS_TO_PRESERVE_DELEGATE_ACCESS , {
6255 [ ONYXKEYS . IS_LOADING_APP ] : true ,
63- [ ONYXKEYS . LAST_FULL_RECONNECT_TIME ] : DateUtils . getDBTime ( ) ,
64- } ) . then ( ( ) => Onyx . clear ( [ ...KEYS_TO_PRESERVE_DELEGATE_ACCESS , ONYXKEYS . IS_LOADING_APP , ONYXKEYS . LAST_FULL_RECONNECT_TIME ] ) ) ;
56+ } ) ;
6557}
6658
6759type WithDelegatedAccess = {
0 commit comments