1
0
mirror of https://github.com/kremalicious/metamask-extension.git synced 2024-12-23 09:52:26 +01:00

Only notify first time lost ids are detected

This commit is contained in:
Dan Finlay 2018-06-04 14:24:45 -07:00
parent f3b385cb09
commit b858cc4b1b

View File

@ -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 })