mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
Don't wait for 3Box initialization during login (#7242)
The 3Box initialization is triggered by login, but it no longer blocks the login from finishing. The 3Box initialization is designed to run in the background, so there's no reason to block on it.
This commit is contained in:
parent
e6e8897434
commit
9541d1e281
@ -757,7 +757,8 @@ module.exports = class MetamaskController extends EventEmitter {
|
|||||||
try {
|
try {
|
||||||
const threeBoxSyncingAllowed = this.threeBoxController.getThreeBoxSyncingState()
|
const threeBoxSyncingAllowed = this.threeBoxController.getThreeBoxSyncingState()
|
||||||
if (threeBoxSyncingAllowed && !this.threeBoxController.box) {
|
if (threeBoxSyncingAllowed && !this.threeBoxController.box) {
|
||||||
await this.threeBoxController.new3Box()
|
// 'await' intentionally omitted to avoid waiting for initialization
|
||||||
|
this.threeBoxController.init()
|
||||||
this.threeBoxController.turnThreeBoxSyncingOn()
|
this.threeBoxController.turnThreeBoxSyncingOn()
|
||||||
} else if (threeBoxSyncingAllowed && this.threeBoxController.box) {
|
} else if (threeBoxSyncingAllowed && this.threeBoxController.box) {
|
||||||
this.threeBoxController.turnThreeBoxSyncingOn()
|
this.threeBoxController.turnThreeBoxSyncingOn()
|
||||||
|
@ -9,7 +9,7 @@ const createTxMeta = require('../../../lib/createTxMeta')
|
|||||||
const EthQuery = require('eth-query')
|
const EthQuery = require('eth-query')
|
||||||
|
|
||||||
const threeBoxSpies = {
|
const threeBoxSpies = {
|
||||||
new3Box: sinon.spy(),
|
init: sinon.spy(),
|
||||||
getThreeBoxAddress: sinon.spy(),
|
getThreeBoxAddress: sinon.spy(),
|
||||||
getThreeBoxSyncingState: sinon.stub().returns(true),
|
getThreeBoxSyncingState: sinon.stub().returns(true),
|
||||||
turnThreeBoxSyncingOn: sinon.spy(),
|
turnThreeBoxSyncingOn: sinon.spy(),
|
||||||
@ -23,7 +23,7 @@ class ThreeBoxControllerMock {
|
|||||||
subscribe: () => {},
|
subscribe: () => {},
|
||||||
getState: () => ({}),
|
getState: () => ({}),
|
||||||
}
|
}
|
||||||
this.new3Box = threeBoxSpies.new3Box
|
this.init = threeBoxSpies.init
|
||||||
this.getThreeBoxAddress = threeBoxSpies.getThreeBoxAddress
|
this.getThreeBoxAddress = threeBoxSpies.getThreeBoxAddress
|
||||||
this.getThreeBoxSyncingState = threeBoxSpies.getThreeBoxSyncingState
|
this.getThreeBoxSyncingState = threeBoxSpies.getThreeBoxSyncingState
|
||||||
this.turnThreeBoxSyncingOn = threeBoxSpies.turnThreeBoxSyncingOn
|
this.turnThreeBoxSyncingOn = threeBoxSpies.turnThreeBoxSyncingOn
|
||||||
@ -108,7 +108,7 @@ describe('MetaMaskController', function () {
|
|||||||
|
|
||||||
beforeEach(async function () {
|
beforeEach(async function () {
|
||||||
await metamaskController.createNewVaultAndKeychain(password)
|
await metamaskController.createNewVaultAndKeychain(password)
|
||||||
threeBoxSpies.new3Box.reset()
|
threeBoxSpies.init.reset()
|
||||||
threeBoxSpies.turnThreeBoxSyncingOn.reset()
|
threeBoxSpies.turnThreeBoxSyncingOn.reset()
|
||||||
})
|
})
|
||||||
|
|
||||||
@ -131,7 +131,7 @@ describe('MetaMaskController', function () {
|
|||||||
|
|
||||||
it('gets the address from threebox and creates a new 3box instance', async () => {
|
it('gets the address from threebox and creates a new 3box instance', async () => {
|
||||||
await metamaskController.submitPassword(password)
|
await metamaskController.submitPassword(password)
|
||||||
assert(threeBoxSpies.new3Box.calledOnce)
|
assert(threeBoxSpies.init.calledOnce)
|
||||||
assert(threeBoxSpies.turnThreeBoxSyncingOn.calledOnce)
|
assert(threeBoxSpies.turnThreeBoxSyncingOn.calledOnce)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user