From 216059f61c3fc4694015ca3571f41dbba38cb872 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=ABck=20V=C3=A9zien?= Date: Tue, 17 Apr 2018 10:49:49 +0200 Subject: [PATCH] Fix setEncryptionKey --- .../SettingsPage/sections/Profile.js | 22 ++++++++++--------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/src/components/SettingsPage/sections/Profile.js b/src/components/SettingsPage/sections/Profile.js index 6352b023..62e2498b 100644 --- a/src/components/SettingsPage/sections/Profile.js +++ b/src/components/SettingsPage/sections/Profile.js @@ -51,16 +51,19 @@ class TabProfile extends PureComponent { isPasswordModalOpened: false, } - setPassword = hash => { + setPassword = password => { const { saveSettings, unlock } = this.props - setEncryptionKey('accounts', hash) - saveSettings({ - password: { - isEnabled: hash !== undefined, - value: hash, - }, + window.requestIdleCallback(() => { + setEncryptionKey('accounts', password) + const hash = password ? bcrypt.hashSync(password, 8) : undefined + saveSettings({ + password: { + isEnabled: hash !== undefined, + value: hash, + }, + }) + unlock() }) - unlock() } debounceSaveUsername = debounce( @@ -94,8 +97,7 @@ class TabProfile extends PureComponent { handleChangePassword = (password: ?string) => { if (password) { - const hash = bcrypt.hashSync(password, 8) - this.setPassword(hash) + this.setPassword(password) this.handleClosePasswordModal() } }