reduce app load from timout from 3s -> 1.5s (#762)
This commit is contained in:
@@ -656,6 +656,11 @@ function ResetStack(): JSX.Element | null {
|
||||
options={{ animation: 'fade', gestureEnabled: false }}
|
||||
// initialParams={{ onAnimationFinish: handleAnimationFinish }}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="SplashReload"
|
||||
component={SplashScreen}
|
||||
options={{ animation: 'none', gestureEnabled: false }}
|
||||
/>
|
||||
<Stack.Screen
|
||||
name="Home"
|
||||
component={HomeComponent}
|
||||
|
||||
+29
-12
@@ -5,7 +5,10 @@ import LottieView from 'lottie-react-native';
|
||||
import Animated, {
|
||||
useSharedValue,
|
||||
useAnimatedStyle,
|
||||
withTiming,
|
||||
withDelay,
|
||||
} from 'react-native-reanimated';
|
||||
import { scheduleOnRN } from 'react-native-worklets';
|
||||
import { CENTER, COLORS } from '../constants';
|
||||
import { useGlobalThemeContext } from '../../context-store/theme';
|
||||
import {
|
||||
@@ -46,6 +49,7 @@ import {
|
||||
initSavingsDb,
|
||||
isSavingsDatabaseOpen,
|
||||
} from '../functions/savings/savingsStorage';
|
||||
|
||||
const BlitzAnimation = require('../assets/BlitzAnimation.json');
|
||||
const errorTxAnimation = require('../assets/errorTxAnimation.json');
|
||||
|
||||
@@ -91,23 +95,35 @@ const SplashScreen = () => {
|
||||
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 = () => {
|
||||
<LottieView
|
||||
ref={animationRef}
|
||||
source={darkModeAnimation}
|
||||
autoPlay={false}
|
||||
speed={0.8}
|
||||
loop={false}
|
||||
style={styles.lottie}
|
||||
|
||||
@@ -14,7 +14,7 @@ const AuthStatusProvider = ({ children }) => {
|
||||
setAuthResetKey(prev => prev + 1);
|
||||
navigationRef.current.reset({
|
||||
index: 0,
|
||||
routes: [{ name: 'Splash' }],
|
||||
routes: [{ name: 'SplashReload' }],
|
||||
});
|
||||
}
|
||||
}, [appState]);
|
||||
|
||||
@@ -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 (
|
||||
|
||||
Reference in New Issue
Block a user