making sure account restore only works once

This commit is contained in:
Blake Kaufman
2026-02-18 08:07:30 -05:00
parent 04304da86f
commit 85558af960
2 changed files with 19 additions and 10 deletions
@@ -25,7 +25,12 @@ export default function RemoveAccountPage(props) {
const navigate = useNavigation();
const handleRemove = useCallback(async () => {
await removeAccount(selectedAccount);
const response = await removeAccount(selectedAccount);
if (!response.didWork) {
navigate.navigate('ErrorScreen', { errorMessage: response.err });
return;
}
if (fromPage === 'SettingsContentHome') {
navigate.popTo('SettingsContentHome', {
for: 'Accounts',
+13 -9
View File
@@ -448,21 +448,25 @@ export const ActiveCustodyAccountProvider = ({ children }) => {
data => JSON.parse(data),
);
if (
hasAutoRestoreCheckRun.current ||
!accountMnemoinc ||
custodyAccounts.length ||
cloudIndex === undefined ||
Number(cloudIndex) <= 0 ||
!didGetToHomepage ||
hasRunRestore
) {
if (hasAutoRestoreCheckRun.current) return;
if (!accountMnemoinc) return;
if (cloudIndex === undefined) return;
if (Number(cloudIndex) <= 0) return;
if (!didGetToHomepage) return;
if (hasRunRestore) return;
if (custodyAccounts.length > 0) {
hasAutoRestoreCheckRun.current = true;
await setLocalStorageItem('hasRunAutoRestore', JSON.stringify(true));
return;
}
console.log('Running auto-restore of derived accounts from cloud...');
hasAutoRestoreCheckRun.current = true;
await setLocalStorageItem('hasRunAutoRestore', JSON.stringify(true));
await restoreDerivedAccountsFromCloud();
}
restoreIfNeeded();
}, [accountMnemoinc, custodyAccounts, masterInfoObject, didGetToHomepage]);