mirror of
https://github.com/BlueWallet/BlueWallet.git
synced 2025-01-19 05:45:15 +01:00
Merge pull request #2696 from BlueWallet/deletefix
FIX: Wallet delete would cause crash
This commit is contained in:
commit
74a0018acf
@ -21,11 +21,17 @@ function WatchConnectivity() {
|
||||
|
||||
useEffect(() => {
|
||||
if (isInstalled && isReachable && walletsInitialized) {
|
||||
sendWalletsToWatch();
|
||||
watchEvents.on('message', handleMessages);
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [walletsInitialized, wallets, preferredFiatCurrency, isReachable, isInstalled]);
|
||||
}, [walletsInitialized, isReachable, isInstalled]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isInstalled && isReachable && walletsInitialized) {
|
||||
sendWalletsToWatch();
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [walletsInitialized, wallets, isReachable, isInstalled]);
|
||||
|
||||
useEffect(() => {
|
||||
if (isInstalled && isReachable && walletsInitialized && preferredFiatCurrency) {
|
||||
@ -33,11 +39,13 @@ function WatchConnectivity() {
|
||||
transferCurrentComplicationUserInfo({
|
||||
preferredFiatCurrency: JSON.parse(preferredFiatCurrency).endPointKey,
|
||||
});
|
||||
sendWalletsToWatch();
|
||||
} catch (e) {
|
||||
console.log('WatchConnectivity useEffect preferredFiatCurrency error');
|
||||
console.log(e);
|
||||
}
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [preferredFiatCurrency, walletsInitialized, isReachable, isInstalled]);
|
||||
|
||||
const handleMessages = (message, reply) => {
|
||||
|
@ -168,6 +168,15 @@ const WalletDetails = () => {
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [walletID]);
|
||||
|
||||
const navigateToOverviewAndDeleteWallet = () => {
|
||||
setIsLoading(true);
|
||||
Notifications.unsubscribe(wallet.getAllExternalAddresses(), [], []);
|
||||
popToTop();
|
||||
deleteWallet(wallet);
|
||||
saveToDisk();
|
||||
ReactNativeHapticFeedback.trigger('notificationSuccess', { ignoreAndroidSystemSettings: false });
|
||||
};
|
||||
|
||||
const presentWalletHasBalanceAlert = useCallback(async () => {
|
||||
ReactNativeHapticFeedback.trigger('notificationWarning', { ignoreAndroidSystemSettings: false });
|
||||
try {
|
||||
@ -178,12 +187,7 @@ const WalletDetails = () => {
|
||||
'plain-text',
|
||||
);
|
||||
if (Number(walletBalanceConfirmation) === wallet.getBalance()) {
|
||||
setIsLoading(true);
|
||||
Notifications.unsubscribe(wallet.getAllExternalAddresses(), [], []);
|
||||
deleteWallet(wallet);
|
||||
ReactNativeHapticFeedback.trigger('notificationSuccess', { ignoreAndroidSystemSettings: false });
|
||||
await saveToDisk();
|
||||
popToTop();
|
||||
navigateToOverviewAndDeleteWallet();
|
||||
} else {
|
||||
ReactNativeHapticFeedback.trigger('notificationError', { ignoreAndroidSystemSettings: false });
|
||||
setIsLoading(false);
|
||||
@ -191,7 +195,7 @@ const WalletDetails = () => {
|
||||
}
|
||||
} catch (_) {}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [popToTop, wallet]);
|
||||
}, []);
|
||||
|
||||
const navigateToWalletExport = () => {
|
||||
navigate('WalletExportRoot', {
|
||||
@ -374,12 +378,7 @@ const WalletDetails = () => {
|
||||
if (wallet.getBalance() > 0 && wallet.allowSend()) {
|
||||
presentWalletHasBalanceAlert();
|
||||
} else {
|
||||
setIsLoading(true);
|
||||
Notifications.unsubscribe(wallet.getAllExternalAddresses(), [], []);
|
||||
popToTop();
|
||||
ReactNativeHapticFeedback.trigger('notificationSuccess', { ignoreAndroidSystemSettings: false });
|
||||
deleteWallet(wallet);
|
||||
saveToDisk();
|
||||
navigateToOverviewAndDeleteWallet();
|
||||
}
|
||||
},
|
||||
style: 'destructive',
|
||||
|
Loading…
Reference in New Issue
Block a user