Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed bootscreen rendering multiple times #33

Merged
merged 2 commits into from
Mar 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading