From 0a8e578e9f5a3412a911ce7711c8c8ca4c1ea08c Mon Sep 17 00:00:00 2001 From: Ben Gotow Date: Wed, 23 Mar 2016 15:56:31 -0700 Subject: [PATCH] fix(tokens): Don't assume that keytar is sync, don't wipe until next save --- src/flux/stores/account-store.coffee | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/src/flux/stores/account-store.coffee b/src/flux/stores/account-store.coffee index 68ec849e7..1af024a30 100644 --- a/src/flux/stores/account-store.coffee +++ b/src/flux/stores/account-store.coffee @@ -45,19 +45,19 @@ class AccountStore extends NylasStore for json in NylasEnv.config.get(configAccountsKey) || [] @_accounts.push((new Account).fromJSON(json)) - # Load tokens using the old config method and save them into the keychain oldTokens = NylasEnv.config.get(configTokensKey) if oldTokens + # Load tokens using the old config method and save them into the keychain + @_tokens = oldTokens for key, val of oldTokens account = @accountForId(key) continue unless account keytar.replacePassword(keytarServiceName, account.emailAddress, val) - NylasEnv.config.set(configTokensKey, null) - - # Load tokens using the new keytar method - @_tokens = {} - for account in @_accounts - @_tokens[account.id] = keytar.getPassword(keytarServiceName, account.emailAddress) + else + # Load tokens using the new keytar method + @_tokens = {} + for account in @_accounts + @_tokens[account.id] = keytar.getPassword(keytarServiceName, account.emailAddress) @_trigger() @@ -73,6 +73,7 @@ class AccountStore extends NylasStore @_version += 1 NylasEnv.config.set(configVersionKey, @_version) NylasEnv.config.set(configAccountsKey, @_accounts) + NylasEnv.config.set(configTokensKey, null) NylasEnv.config.save() @_trigger()