Remove deep link path and prevent re-render from useEffect #7

Merged
nabarun merged 4 commits from deep-stack/laconic-wallet-web:sk-fix-memory-leak into main 2024-08-01 06:18:03 +00:00
2 changed files with 8 additions and 24 deletions
Showing only changes of commit ce462f3ad2 - Show all commits

View File

@ -15,14 +15,7 @@ import { WalletConnectProvider } from './context/WalletConnectContext';
globalThis.Buffer = Buffer; globalThis.Buffer = Buffer;
const linking = { const linking = {
prefixes: ['https://wallet.laconic.com'], prefixes: ['https://wallet.laconic.com']
config: {
screens: {
SignRequest: {
path: 'sign/:namespace/:chaindId/:address/:message',
},
},
},
}; };
const theme = { const theme = {

View File

@ -1,7 +1,6 @@
import React, { useCallback, useEffect, useMemo, useState } from 'react'; import React, { useCallback, useEffect, useMemo, useState } from 'react';
import { Image, ScrollView, View } from 'react-native'; import { Image, ScrollView, View } from 'react-native';
import { ActivityIndicator, Button, Text, Appbar } from 'react-native-paper'; import { ActivityIndicator, Button, Text, Appbar } from 'react-native-paper';
import _ from 'lodash';
import { useNavigation } from '@react-navigation/native'; import { useNavigation } from '@react-navigation/native';
import { import {
@ -50,7 +49,7 @@ const SignRequest = ({ route }: SignRequestProps) => {
const isCosmosSignDirect = useMemo(() => { const isCosmosSignDirect = useMemo(() => {
const requestParams = route.params.requestEvent; const requestParams = route.params.requestEvent;
if (!requestParams) { if (!requestParams?.id) {
return false; return false;
} }
@ -60,7 +59,7 @@ const SignRequest = ({ route }: SignRequestProps) => {
const isEthSendTransaction = useMemo(() => { const isEthSendTransaction = useMemo(() => {
const requestParams = route.params.requestEvent; const requestParams = route.params.requestEvent;
if (!requestParams) { if (!requestParams?.id) {
return false; return false;
} }
@ -87,21 +86,13 @@ const SignRequest = ({ route }: SignRequestProps) => {
return; return;
} }
if (_.isEqual(requestAccount, account)) { setAccount(requestAccount);
setAccount(requestAccount); setMessage(decodeURIComponent(requestMessage));
} setNamespace(requestNamespace);
if (requestMessage !== message) { setChainId(requestChainId);
setMessage(decodeURIComponent(requestMessage));
}
if (requestNamespace !== namespace) {
setNamespace(requestNamespace);
}
if (requestChainId !== chainId) {
setChainId(requestChainId);
}
setIsLoading(false); setIsLoading(false);
}, },
[account, message, navigation, namespace, chainId], [navigation],
); );
const sanitizePath = useCallback( const sanitizePath = useCallback(