Skip to content

Commit

Permalink
Clean up wallet persistance
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Risch authored and Alex Risch committed Feb 12, 2024
1 parent 6b9ae95 commit f2ea3b8
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/context/ClientContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import React, {
useState,
} from 'react';
import {AppConfig} from '../consts/AppConfig';
import {getClientKeys} from '../services/encryptedStorage';
import {clearClientKeys, getClientKeys} from '../services/encryptedStorage';

interface ClientContextValue {
client: Client<unknown> | null;
Expand All @@ -34,9 +34,13 @@ export const ClientProvider: FC<PropsWithChildren> = ({children}) => {
if (status === 'unknown' || status === 'connecting') {
return;
}
if (!address) {
if (status === 'disconnected') {
return setLoading(false);
}
if (!address) {
// Address still shows as undefined even when connected
return;
}
getClientKeys(address as `0x${string}`)
.then(keys => {
if (!keys) {
Expand All @@ -52,6 +56,7 @@ export const ClientProvider: FC<PropsWithChildren> = ({children}) => {
setLoading(false);
})
.catch(() => {
clearClientKeys(address as `0x${string}`);
setLoading(false);
});
})
Expand Down
7 changes: 6 additions & 1 deletion src/navigation/AppNavigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ export const AppNavigation = () => {
</LoadingStack.Navigator>
)}
{!loading && !client && (
<OnboardingStack.Navigator screenOptions={{headerShown: false}}>
<OnboardingStack.Navigator
screenOptions={{
headerShown: false,
// https://github.com/Kureev/react-native-blur/issues/595
animation: Platform.OS === 'android' ? 'none' : 'default',
}}>
<OnboardingStack.Screen
name={ScreenNames.OnboardingConnectWallet}
component={OnboardingConnectWalletScreen}
Expand Down

0 comments on commit f2ea3b8

Please sign in to comment.