Skip to content

Commit

Permalink
Fixed bootscreen rendering multiple times (#33)
Browse files Browse the repository at this point in the history
* Fixed bootscreen rendering multiple times

* bump version to 0.0.10
  • Loading branch information
tortuvshin committed Mar 25, 2024
1 parent 6ea9414 commit 358883e
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 35 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "storefrontapp",
"version": "0.0.9",
"version": "0.0.10",
"private": true,
"scripts": {
"android": "react-native run-android",
Expand Down
66 changes: 32 additions & 34 deletions src/features/Core/screens/BootScreen.js
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import SetupWarningScreen from 'exceptions/SetupWarningScreen';
import { useStorefront } from 'hooks';
import React, { useEffect, useState } from 'react';
import { SafeAreaView, View, ActivityIndicator } from 'react-native';
import { initStripe } from '@stripe/stripe-react-native';
import { ActivityIndicator, SafeAreaView, View } from 'react-native';
import RNBootSplash from 'react-native-bootsplash';
import { tailwind } from 'tailwind';
import { hasRequiredKeys, logError } from 'utils';
import { useStorefront } from 'hooks';
import { set } from 'utils/Storage';
import { setI18nConfig } from 'utils/Localize';
import { tailwind } from 'tailwind';
import RNBootSplash from 'react-native-bootsplash';
import SetupWarningScreen from 'exceptions/SetupWarningScreen';
import config from 'config';

const { STRIPE_KEY, APP_IDENTIFIER } = config;
import { set } from 'utils/Storage';

/**
* BootScreen is a simple initialization screen, will load
Expand All @@ -37,32 +33,34 @@ const BootScreen = ({ navigation }) => {
// Initialize i18n
setI18nConfig();

// Fetch the about() information
storefront
.about()
.then((info) => {
// Store storefront/network info
set('info', info);
useEffect(() => {
// Fetch the about() information
storefront
.about()
.then((info) => {
// Store storefront/network info
set('info', info);

// if is single store only go to storefront screens
if (info.is_store) {
return navigation.navigate('StorefrontScreen', { info });
}
// if is single store only go to storefront screens
if (info.is_store) {
return navigation.navigate('StorefrontScreen', { info });
}

// if is network/multi-vendor
if (info.is_network) {
return navigation.navigate('NetworkScreen', { info });
}
})
.catch((error) => {
setError(error);
logError(error, '[ Error fetching storefront info! ]');
})
.finally(() => {
setTimeout(() => {
RNBootSplash.hide();
}, 300);
});
// if is network/multi-vendor
if (info.is_network) {
return navigation.navigate('NetworkScreen', { info });
}
})
.catch((error) => {
setError(error);
logError(error, '[ Error fetching storefront info! ]');
})
.finally(() => {
setTimeout(() => {
RNBootSplash.hide();
}, 300);
});
}, []);

if (error) {
return <SetupWarningScreen error={error} />;
Expand Down

0 comments on commit 358883e

Please sign in to comment.