aboutsummaryrefslogtreecommitdiffstats
path: root/app
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-02-03 08:59:15 +0800
committerkumavis <aaron@kumavis.me>2017-02-03 08:59:15 +0800
commit134a4c7bc3dcb8d750de4867f7dade413f438981 (patch)
tree97c787f22a6c735ea1192fee9b48487548e17d66 /app
parent5c5aa6ea012b6a5d0cb8e8386ac0429f023c9e1a (diff)
downloadtangerine-wallet-browser-134a4c7bc3dcb8d750de4867f7dade413f438981.tar
tangerine-wallet-browser-134a4c7bc3dcb8d750de4867f7dade413f438981.tar.gz
tangerine-wallet-browser-134a4c7bc3dcb8d750de4867f7dade413f438981.tar.bz2
tangerine-wallet-browser-134a4c7bc3dcb8d750de4867f7dade413f438981.tar.lz
tangerine-wallet-browser-134a4c7bc3dcb8d750de4867f7dade413f438981.tar.xz
tangerine-wallet-browser-134a4c7bc3dcb8d750de4867f7dade413f438981.tar.zst
tangerine-wallet-browser-134a4c7bc3dcb8d750de4867f7dade413f438981.zip
keyring - manage isUnlocked in memStore
Diffstat (limited to 'app')
-rw-r--r--app/scripts/keyring-controller.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/app/scripts/keyring-controller.js b/app/scripts/keyring-controller.js
index 023dcbcab..59b8486ff 100644
--- a/app/scripts/keyring-controller.js
+++ b/app/scripts/keyring-controller.js
@@ -29,6 +29,7 @@ class KeyringController extends EventEmitter {
this.keyringTypes = keyringTypes
this.store = new ObservableStore(initState)
this.memStore = new ObservableStore({
+ isUnlocked: false,
keyringTypes: this.keyringTypes.map(krt => krt.type),
keyrings: [],
identities: {},
@@ -74,7 +75,7 @@ class KeyringController extends EventEmitter {
const memState = this.memStore.getState()
const result = {
// computed
- isUnlocked: (!!this.password),
+ isUnlocked: memState.isUnlocked,
// memStore
keyringTypes: memState.keyringTypes,
identities: memState.identities,
@@ -144,7 +145,10 @@ class KeyringController extends EventEmitter {
//
// This method deallocates all secrets, and effectively locks metamask.
setLocked () {
+ // set locked
this.password = null
+ this.memStore.updateState({ isUnlocked: false })
+ // remove keyrings
this.keyrings = []
this._updateMemStoreKeyrings()
return this.fullUpdate()
@@ -382,6 +386,7 @@ class KeyringController extends EventEmitter {
persistAllKeyrings (password = this.password) {
if (typeof password === 'string') {
this.password = password
+ this.memStore.updateState({ isUnlocked: true })
}
return Promise.all(this.keyrings.map((keyring) => {
return Promise.all([keyring.type, keyring.serialize()])
@@ -418,6 +423,7 @@ class KeyringController extends EventEmitter {
return this.encryptor.decrypt(password, encryptedVault)
.then((vault) => {
this.password = password
+ this.memStore.updateState({ isUnlocked: true })
vault.forEach(this.restoreKeyring.bind(this))
return this.keyrings
})