Only notify first time lost ids are detected

feature/default_network_editable
Dan Finlay 7 years ago
parent f3b385cb09
commit b858cc4b1b
  1. 10
      app/scripts/controllers/preferences.js

@ -111,15 +111,17 @@ class PreferencesController {
*/
syncAddresses (addresses) {
let { identities, lostIdentities } = this.store.getState()
let newlyLost = {}
Object.keys(identities).forEach((identity) => {
if (!addresses.includes(identity)) {
delete identities[identity]
lostIdentities[identity] = identities[identity]
newlyLost[identity] = identities[identity]
}
})
// Identities are no longer present.
if (Object.keys(lostIdentities).length > 0) {
if (Object.keys(newlyLost).length > 0) {
// timeout to prevent blocking the thread:
setTimeout(() => {
@ -130,6 +132,10 @@ class PreferencesController {
const uri = 'https://diagnostics.metamask.io/v1/orphanedAccounts'
notifier.notify(uri, { accounts: Object.keys(lostIdentities) })
.catch(log.error)
for (let key in newlyLost) {
lostIdentities[key] = newlyLost[key]
}
}
this.store.updateState({ identities, lostIdentities })

Loading…
Cancel
Save