Skip to content

Commit

Permalink
chore: improve state changes while resetting account
Browse files Browse the repository at this point in the history
  • Loading branch information
kalashshah committed Feb 19, 2024
1 parent 2d29647 commit 02386d5
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/contexts/PushApiContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ const PushApiContextProvider = ({children}: {children: React.ReactNode}) => {
ModalComponent: AddressMismatchModal,
showModal: showAddressMismatchModal,
hideModal: hideAddressMismatchModal,
isModalOpen: isAddressMismatchModalOpen,
} = useModalBlur();

const getReadOnlyInstance = async (overrideAccount?: string) => {
Expand Down Expand Up @@ -214,11 +215,11 @@ const PushApiContextProvider = ({children}: {children: React.ReactNode}) => {
address.toLowerCase() !== walletAddress.toLowerCase()
) {
// If the user tries to unlock profile with different wallet
showAddressMismatchModal();
if (!isAddressMismatchModalOpen) showAddressMismatchModal();
} else {
refreshUserPushSDKInstance();
}
}, [isConnected, users]);
}, [isConnected, address]);

return (
<PushApiContext.Provider
Expand All @@ -227,7 +228,6 @@ const PushApiContextProvider = ({children}: {children: React.ReactNode}) => {
setUserPushSDKInstance,
refreshUserPushSDKInstance,
getReadWriteInstance,
// fakeSigner,
userInfo,
readOnlyMode,
isLoading,
Expand Down Expand Up @@ -277,8 +277,8 @@ const PushApiContextProvider = ({children}: {children: React.ReactNode}) => {
dispatch(setInitialSignin(newUsers[0]));
dispatch(setAuthType(GLOBALS.AUTH_TYPE.WALLET_CONNECT));
dispatch(setIsGuest(undefined));
await login(newUsers);
hideAddressMismatchModal();
await login(newUsers);
await getReadWriteInstance(address);
},
},
Expand Down
6 changes: 5 additions & 1 deletion src/navigation/screens/SetupCompleteScreen.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {useNavigation} from '@react-navigation/native';
import React from 'react';
import React, {useState} from 'react';
import {ActivityIndicator, Image, StyleSheet, Text, View} from 'react-native';
import {useSelector} from 'react-redux';
import GLOBALS from 'src/Globals';
Expand All @@ -11,13 +11,16 @@ import {selectUserDomain} from 'src/redux/authSlice';
import {getTrimmedAddress} from './chats/helpers/chatAddressFormatter';

const SetupCompleteScreen = () => {
const [loading, setLoading] = useState<boolean>(false);
const {userInfo, getReadWriteInstance} = usePushApi();
const domain = useSelector(selectUserDomain);
const navigation = useNavigation();

const decryptPushProfile = async () => {
setLoading(true);
await getReadWriteInstance();
loadNextScreen();
setLoading(false);
};

const loadNextScreen = () => {
Expand All @@ -36,6 +39,7 @@ const SetupCompleteScreen = () => {
fontColor: GLOBALS.COLORS.WHITE,
onPress: decryptPushProfile,
disabled: !userInfo,
loading: loading,
},
{
title: 'Skip for now',
Expand Down

0 comments on commit 02386d5

Please sign in to comment.