Skip to content

Commit

Permalink
fix: Black screen
Browse files Browse the repository at this point in the history
  • Loading branch information
limpbrains committed May 13, 2024
1 parent b4a73d2 commit 3aa7c76
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 45 deletions.
59 changes: 18 additions & 41 deletions src/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
import React, {
memo,
ReactElement,
useMemo,
useEffect,
useCallback,
useState,
} from 'react';
import React, { memo, ReactElement, useMemo, useEffect, useState } from 'react';
import { Platform, NativeModules } from 'react-native';
import Toast from 'react-native-toast-message';
import QuickActions from 'react-native-quick-actions';
Expand Down Expand Up @@ -60,45 +53,29 @@ const App = (): ReactElement => {
checkForAppUpdate();
}, []);

const RootComponent = useCallback((): ReactElement => {
if (!isReady) {
return <></>;
}

if (showRecovery) {
return <RecoveryNavigator />;
}

if (hasCriticalUpdate) {
return <AppUpdate />;
}

if (walletExists) {
return (
<SlashtagsProvider>
<SlashtagsProvider2>
{requiresRemoteRestore ? <RestoringScreen /> : <AppOnboarded />}
</SlashtagsProvider2>
</SlashtagsProvider>
);
}

return <OnboardingNavigator />;
}, [
isReady,
showRecovery,
hasCriticalUpdate,
walletExists,
requiresRemoteRestore,
]);

const currentTheme = useMemo(() => getTheme(theme), [theme]);

return (
<ThemeProvider theme={currentTheme}>
<SafeAreaProvider>
<StatusBar />
<RootComponent />

{!isReady ? (
<></>
) : showRecovery ? (
<RecoveryNavigator />
) : hasCriticalUpdate ? (
<AppUpdate />
) : walletExists ? (
<SlashtagsProvider>
<SlashtagsProvider2>
{requiresRemoteRestore ? <RestoringScreen /> : <AppOnboarded />}
</SlashtagsProvider2>
</SlashtagsProvider>
) : (
<OnboardingNavigator />
)}

<Toast config={toastConfig} />
</SafeAreaProvider>
</ThemeProvider>
Expand Down
6 changes: 3 additions & 3 deletions src/screens/Onboarding/RestoreFromSeed.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ const RestoreFromSeed = (): ReactElement => {
setIsRestoringWallet(true);
dispatch(verifyBackup());

// Tells component within slashtags provider that it needs to handle restoring from remote backup
dispatch(updateUser({ requiresRemoteRestore: true }));

const res = await restoreSeed({
mnemonic: seed.join(' '),
bip39Passphrase,
Expand All @@ -120,9 +123,6 @@ const RestoreFromSeed = (): ReactElement => {
});
return;
}

//Tells component within slashtags provider that it needs to handle restoring from remote backup
dispatch(updateUser({ requiresRemoteRestore: true }));
};

const handleAdvanced = (): void => {
Expand Down
3 changes: 3 additions & 0 deletions src/store/actions/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,13 +120,16 @@ export const createWallet = async ({

export const createDefaultWalletStructure = async ({
walletName = 'wallet0',
seedHash,
}: {
walletName?: TWalletName;
seedHash: string;
}): Promise<Result<string>> => {
try {
const payload: IWallets = {
[walletName]: getDefaultWalletShape(),
};
payload[walletName].seedHash = seedHash;
dispatch({
type: actions.CREATE_WALLET,
payload,
Expand Down
5 changes: 4 additions & 1 deletion src/utils/wallet/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -896,7 +896,10 @@ export const createDefaultWallet = async ({
const seed = await bip39.mnemonicToSeed(mnemonic, bip39Passphrase);
await setKeychainSlashtagsPrimaryKey(seed);

await createDefaultWalletStructure({ walletName });
await createDefaultWalletStructure({
walletName,
seedHash: seedHash(seed),
});

let gapLimitOptions = getDefaultGapLimitOptions();
if (restore) {
Expand Down

0 comments on commit 3aa7c76

Please sign in to comment.