1- import { useCallback , useEffect } from 'react' ;
1+ import { useEffect } from 'react' ;
22import CONFIG from './CONFIG' ;
33import CONST from './CONST' ;
44import useOnyx from './hooks/useOnyx' ;
@@ -9,35 +9,25 @@ import Log from './libs/Log';
99import { endSpan , startSpan } from './libs/telemetry/activeSpans' ;
1010import { addBootsplashBreadcrumb } from './libs/telemetry/bootsplashTelemetry' ;
1111import ONYXKEYS from './ONYXKEYS' ;
12- import { useSplashScreenActions , useSplashScreenState } from './SplashScreenStateContext' ;
12+ import { useSplashScreenActions } from './SplashScreenStateContext' ;
1313import isLoadingOnyxValue from './types/utils/isLoadingOnyxValue' ;
1414
1515function HybridAppHandler ( ) {
16- const { splashScreenState} = useSplashScreenState ( ) ;
1716 const { setSplashScreenState} = useSplashScreenActions ( ) ;
1817 const [ tryNewDot , tryNewDotMetadata ] = useOnyx ( ONYXKEYS . NVP_TRY_NEW_DOT ) ;
1918 const isLoadingTryNewDot = isLoadingOnyxValue ( tryNewDotMetadata ) ;
2019
21- const finalizeTransitionFromOldDot = useCallback (
22- ( hybridAppSettings : HybridAppSettings ) => {
23- const loggedOutFromOldDot = ! ! hybridAppSettings . hybridApp . loggedOutFromOldDot ;
20+ const finalizeTransitionFromOldDot = ( hybridAppSettings : HybridAppSettings ) => {
21+ const loggedOutFromOldDot = ! ! hybridAppSettings . hybridApp . loggedOutFromOldDot ;
2422
25- setupNewDotAfterTransitionFromOldDot ( hybridAppSettings , tryNewDot ) . then ( ( ) => {
26- if ( splashScreenState !== CONST . BOOT_SPLASH_STATE . VISIBLE ) {
27- addBootsplashBreadcrumb ( 'HybridAppHandler: Splash no longer VISIBLE, skipping state transition' , { splashScreenState} ) ;
28- return ;
29- }
30-
31- if ( loggedOutFromOldDot ) {
32- setSplashScreenState ( CONST . BOOT_SPLASH_STATE . HIDDEN ) ;
33- endSpan ( CONST . TELEMETRY . SPAN_OD_ND_TRANSITION_LOGGED_OUT ) ;
34- } else {
35- setSplashScreenState ( CONST . BOOT_SPLASH_STATE . READY_TO_BE_HIDDEN ) ;
36- }
37- } ) ;
38- } ,
39- [ setSplashScreenState , splashScreenState , tryNewDot ] ,
40- ) ;
23+ setupNewDotAfterTransitionFromOldDot ( hybridAppSettings , tryNewDot ) . then ( ( ) => {
24+ if ( loggedOutFromOldDot ) {
25+ endSpan ( CONST . TELEMETRY . SPAN_OD_ND_TRANSITION_LOGGED_OUT ) ;
26+ } else {
27+ setSplashScreenState ( CONST . BOOT_SPLASH_STATE . READY_TO_BE_HIDDEN ) ;
28+ }
29+ } ) ;
30+ } ;
4131
4232 useEffect ( ( ) => {
4333 if ( ! CONFIG . IS_HYBRID_APP || isLoadingTryNewDot ) {
@@ -55,6 +45,14 @@ function HybridAppHandler() {
5545
5646 addBootsplashBreadcrumb ( 'HybridAppHandler: Settings received' , { loggedOutFromOldDot : String ( ! ! hybridAppSettings . hybridApp . loggedOutFromOldDot ) } ) ;
5747
48+ // Resolve splash state ASAP — this is the earliest moment we know
49+ // whether the native splash is on screen or not
50+ if ( hybridAppSettings . hybridApp . loggedOutFromOldDot ) {
51+ setSplashScreenState ( CONST . BOOT_SPLASH_STATE . HIDDEN ) ;
52+ } else {
53+ setSplashScreenState ( CONST . BOOT_SPLASH_STATE . VISIBLE ) ;
54+ }
55+
5856 if ( hybridAppSettings . hybridApp . loggedOutFromOldDot ) {
5957 startSpan ( CONST . TELEMETRY . SPAN_OD_ND_TRANSITION_LOGGED_OUT , {
6058 name : CONST . TELEMETRY . SPAN_OD_ND_TRANSITION_LOGGED_OUT ,
@@ -71,7 +69,7 @@ function HybridAppHandler() {
7169
7270 finalizeTransitionFromOldDot ( hybridAppSettings ) ;
7371 } ) ;
74- } , [ finalizeTransitionFromOldDot , isLoadingTryNewDot ] ) ;
72+ } , [ finalizeTransitionFromOldDot , isLoadingTryNewDot , setSplashScreenState ] ) ;
7573
7674 return null ;
7775}
0 commit comments