From b6ede844d8596a34dface8bb1cf4fcc07c43f322 Mon Sep 17 00:00:00 2001 From: Blake Kaufman <68204898+BlakeKaufman@users.noreply.github.com> Date: Thu, 9 Apr 2026 11:37:55 -0400 Subject: [PATCH] reduce app load from timout from 3s -> 1.5s (#762) --- App.tsx | 5 ++++ app/screens/splashScreen.js | 41 +++++++++++++++++++++++---------- context-store/authContext.js | 2 +- context-store/webViewContext.js | 3 +++ 4 files changed, 38 insertions(+), 13 deletions(-) diff --git a/App.tsx b/App.tsx index d6075494..dc60bf73 100644 --- a/App.tsx +++ b/App.tsx @@ -656,6 +656,11 @@ function ResetStack(): JSX.Element | null { options={{ animation: 'fade', gestureEnabled: false }} // initialParams={{ onAnimationFinish: handleAnimationFinish }} /> + { fade: true, }); ExpoSplashScreen.hideAsync(); + + const tablesOpen = + isMessagesDatabaseOpen() && + isGiftCardDatabaseOpen() && + isSavedPOSTxsDatabaseOpen() && + isSparkTxDatabaseOpen() && + isRoostockDatabaseOpen() && + isGiftDatabaseOpen() && + isSavingsDatabaseOpen(); + + if (tablesOpen) { + animationRef.current?.pause(); + // Warm restart fast path: fade out in 0.5s, no animation + const goHome = () => navigate.replace('Home'); + opacity.value = withDelay( + 750, + withTiming(0, { duration: 500 }, finished => { + if (finished) scheduleOnRN(goHome); + }), + ); + return; + } + try { setTimeout(() => { animationRef.current?.play(); }, 500); - if ( - isMessagesDatabaseOpen() && - isGiftCardDatabaseOpen() && - isSavedPOSTxsDatabaseOpen() && - isSparkTxDatabaseOpen() && - isRoostockDatabaseOpen() && - isGiftDatabaseOpen() && - isSavingsDatabaseOpen() - ) { - console.log('Tables are already opened, blocking...'); - } else { - // Initialize databases one at a time + if (!tablesOpen) { const didOpen = await initializeDatabase(); const giftCardTable = await initializeGiftCardDatabase(); const posTransactions = await initializePOSTransactionsDatabase(); @@ -202,6 +218,7 @@ const SplashScreen = () => { { setAuthResetKey(prev => prev + 1); navigationRef.current.reset({ index: 0, - routes: [{ name: 'Splash' }], + routes: [{ name: 'SplashReload' }], }); } }, [appState]); diff --git a/context-store/webViewContext.js b/context-store/webViewContext.js index 5aa38b58..cf319354 100644 --- a/context-store/webViewContext.js +++ b/context-store/webViewContext.js @@ -496,6 +496,7 @@ export const WebViewProvider = ({ children }) => { const blockReset = currentRoutes?.includes('Splash') || + currentRoutes?.includes('SplashReload') || currentRoutes?.includes('Home') || currentRoutes?.includes('ConnectingToNodeLoadingScreen'); @@ -1150,6 +1151,7 @@ export const WebViewProvider = ({ children }) => { const blockReset = currentRoutes?.includes('Splash') || + currentRoutes?.includes('SplashReload') || currentRoutes?.includes('Home') || currentRoutes?.includes('ConnectingToNodeLoadingScreen'); @@ -1395,6 +1397,7 @@ export const WebViewProvider = ({ children }) => { transitionWvState(WV_STATES.LOADING, 'onLoadStart'); webViewLoadState.current = 'loading'; onLoadEndCalledRef.current = false; + didRunHandshakeRef.current = false; }} onLoadProgress={({ nativeEvent }) => { if (