From 35e922bc6d89fd66ea879cf6557d14bc52fd7aa1 Mon Sep 17 00:00:00 2001 From: cakesoft-vaibhav Date: Thu, 23 Jan 2025 10:16:27 +0530 Subject: [PATCH 1/2] fix: SS-Otp clear --- src/screens/Vault/HardwareModalMap.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/screens/Vault/HardwareModalMap.tsx b/src/screens/Vault/HardwareModalMap.tsx index 5e25a91f2..c6d052880 100644 --- a/src/screens/Vault/HardwareModalMap.tsx +++ b/src/screens/Vault/HardwareModalMap.tsx @@ -1178,6 +1178,8 @@ function HardwareModalMap({ setInProgress(false); close(); showToast('Error in Health check', ); + } finally { + setOtp(''); } } }; From 5dc86812ac9be2c63a1ece697aa471eb8041dde1 Mon Sep 17 00:00:00 2001 From: cakesoft-vaibhav Date: Thu, 23 Jan 2025 12:21:47 +0530 Subject: [PATCH 2/2] feat: NodeUpdateAndBackup --- .../AppSettings/Node/NodeSelection.tsx | 2 ++ src/screens/AppSettings/Node/NodeSettings.tsx | 2 ++ src/store/sagas/bhr.ts | 22 +++++++++++++++++-- 3 files changed, 24 insertions(+), 2 deletions(-) diff --git a/src/screens/AppSettings/Node/NodeSelection.tsx b/src/screens/AppSettings/Node/NodeSelection.tsx index ed9c656fb..6a425743e 100644 --- a/src/screens/AppSettings/Node/NodeSelection.tsx +++ b/src/screens/AppSettings/Node/NodeSelection.tsx @@ -31,6 +31,7 @@ import { CommonActions, useNavigation } from '@react-navigation/native'; import { LocalizationContext } from 'src/context/Localization/LocContext'; import config from 'src/utils/service-utilities/config'; import { NetworkType } from 'src/services/wallets/enums'; +import { updateAppImage } from 'src/store/sagaActions/bhr'; const PrivateElectrum = ({ host, port, useSSL, setHost, setPort, setUseSSL }) => { return ( @@ -109,6 +110,7 @@ const NodeSelection = () => { if (saved) { const updatedNodeList = Node.getAllNodes(); setNodeList(updatedNodeList); + dispatch(updateAppImage({ wallets: null, signers: null })); const newNode = updatedNodeList.find( (node) => node.host === nodeToSave.host && node.port === nodeToSave.port ); diff --git a/src/screens/AppSettings/Node/NodeSettings.tsx b/src/screens/AppSettings/Node/NodeSettings.tsx index 4872d6520..2bf300da2 100644 --- a/src/screens/AppSettings/Node/NodeSettings.tsx +++ b/src/screens/AppSettings/Node/NodeSettings.tsx @@ -24,6 +24,7 @@ import { CommonActions, useNavigation } from '@react-navigation/native'; import ServerItem from './components/ServerItem'; import WarningNote from 'src/components/WarningNote'; import ActivityIndicatorView from 'src/components/AppActivityIndicator/ActivityIndicatorView'; +import { updateAppImage } from 'src/store/sagaActions/bhr'; function ElectrumDisconnectWarningContent() { const { colorMode } = useColorMode(); @@ -68,6 +69,7 @@ function NodeSettings() { if (status) { const updatedNodes = Node.getAllNodes(); setNodeList(updatedNodes); + dispatch(updateAppImage({ wallets: null, signers: null })); } }; diff --git a/src/store/sagas/bhr.ts b/src/store/sagas/bhr.ts index 0f5400eec..0be7be8a6 100644 --- a/src/store/sagas/bhr.ts +++ b/src/store/sagas/bhr.ts @@ -582,11 +582,18 @@ function* recoverApp( title: 'Restored version', }); + const existingNodes: NodeDetail[] = yield call(dbManager.getCollection, RealmSchema.NodeConnect); if (appImage.nodes) { for (const node of appImage.nodes) { try { - const decrptedNode = JSON.parse(decrypt(encryptionKey, node)); - yield call(dbManager.createObject, RealmSchema.NodeConnect, decrptedNode); + const decryptedNode = JSON.parse(decrypt(encryptionKey, node)); + const isExistingNode = existingNodes.some( + (existingNode) => + existingNode.id === decryptedNode.id || + (existingNode.host === decryptedNode.host && existingNode.port === decryptedNode.port) + ); + if (isExistingNode) continue; + yield call(dbManager.createObject, RealmSchema.NodeConnect, decryptedNode); } catch (err) { console.log('Error recovering a node: ', err); continue; @@ -972,6 +979,16 @@ function* backupAllSignersAndVaultsWorker() { }; } + const nodes: NodeDetail[] = yield call(dbManager.getCollection, RealmSchema.NodeConnect); + const nodesToUpdate = []; + if (nodes && nodes.length > 0) { + for (const index in nodes) { + const node = nodes[index]; + node.isConnected = false; + const encryptedNode = encrypt(encryptionKey, JSON.stringify(node)); + nodesToUpdate.push(encryptedNode); + } + } yield call(Relay.backupAllSignersAndVaults, { appId: id, publicId, @@ -981,6 +998,7 @@ function* backupAllSignersAndVaultsWorker() { networkType, subscription: JSON.stringify(subscription), version, + nodes: nodesToUpdate, }); yield put(setBackupAllSuccess(true)); yield put(setPendingAllBackup(false));