From 2d8e2558c93277b81ec51b4cdeadde0a703571b5 Mon Sep 17 00:00:00 2001 From: Etienne Dusseault Date: Thu, 16 Jul 2020 13:27:14 +0800 Subject: [PATCH] ChoosePassword: update preferencesControllerState after adding accounts, before passing into PreferencesController.update() --- app/components/Views/ChoosePassword/index.js | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/app/components/Views/ChoosePassword/index.js b/app/components/Views/ChoosePassword/index.js index 9ae545ad0f1..07c47b3f105 100644 --- a/app/components/Views/ChoosePassword/index.js +++ b/app/components/Views/ChoosePassword/index.js @@ -288,13 +288,17 @@ class ChoosePassword extends PureComponent { // Get props to restore vault const hdKeyring = KeyringController.state.keyrings[0]; const existingAccountCount = hdKeyring.accounts.length; - const preferencesControllerState = PreferencesController.state; const selectedAddress = this.props.selectedAddress; + let preferencesControllerState = PreferencesController.state; // Create previous accounts again for (let i = 0; i < existingAccountCount - 1; i++) { await KeyringController.addNewAccount(); } + + // Reset preferencesControllerState + preferencesControllerState = PreferencesController.state; + // Set preferencesControllerState again await PreferencesController.update(preferencesControllerState); // Reselect previous selected account if still available