diff --git a/src/components/login/login.js b/src/components/login/login.js index cfc3dd103..ede139db4 100644 --- a/src/components/login/login.js +++ b/src/components/login/login.js @@ -34,7 +34,19 @@ app.component('login', { custom: true, address: 'http://localhost:8000', }]; + this.network = this.networks[0]; + try { + const network = JSON.parse(this.$cookies.get('network')); + if (network.custom) { + this.networks[2].address = network.address; + this.network = this.networks[2]; + } else if (network.testnet) { + this.network = this.networks[1]; + } + } catch (e) { + this.$cookies.remove('network'); + } this.$scope.$watch('$ctrl.input_passphrase', val => this.valid = this.Passphrase.isValidPassphrase(val)); this.$timeout(this.devTestAccount.bind(this), 200); @@ -51,6 +63,9 @@ app.component('login', { this.passConfirmSubmit(args.passphrase); } }); + this.$scope.$on('onSignupCancel', () => { + this.generatingNewPassphrase = false; + }); } /** @@ -68,6 +83,7 @@ app.component('login', { passphrase: this.Passphrase.normalize(_passphrase), network: this.network, }); + this.$cookies.put('network', JSON.stringify(this.network)); this.$state.go(this.$rootScope.landingUrl || 'main.transactions'); } else { this.dialog.errorToast(`Failed to connect to node ${this.network.address}`); diff --git a/src/components/passphrase/savePassphrase.js b/src/components/passphrase/savePassphrase.js index 0e5aea4a9..d613ad9e3 100644 --- a/src/components/passphrase/savePassphrase.js +++ b/src/components/passphrase/savePassphrase.js @@ -7,9 +7,9 @@ app.component('savePassphrase', { okButtonLabel: '<', }, controller: class savePassphrase { - constructor($scope, $state, $mdDialog) { + constructor($scope, $rootScope, $mdDialog) { this.$mdDialog = $mdDialog; - this.$state = $state; + this.$rootScope = $rootScope; this.step = 1; @@ -31,7 +31,6 @@ app.component('savePassphrase', { ok() { this.$mdDialog.hide(); - this.$state.reload(); } back() { @@ -40,7 +39,7 @@ app.component('savePassphrase', { close() { this.$mdDialog.cancel(); - this.$state.reload(); + this.$rootScope.$broadcast('onSignupCancel'); } }, }); diff --git a/test/components/passphrase/savePassphrase.spec.js b/test/components/passphrase/savePassphrase.spec.js index 0f0925c1b..459610fab 100644 --- a/test/components/passphrase/savePassphrase.spec.js +++ b/test/components/passphrase/savePassphrase.spec.js @@ -39,7 +39,6 @@ describe('Save passphrase component', () => { let controller; let $componentController; let dialogMock; - let stateMock; beforeEach(inject((_$componentController_) => { $componentController = _$componentController_; @@ -49,32 +48,24 @@ describe('Save passphrase component', () => { $scope = $rootScope.$new(); $scope.passphrase = PASSPHRASE; controller = $componentController('savePassphrase', $scope, {}); - dialogMock = sinon.mock(controller.$mdDialog); - stateMock = sinon.mock(controller.$state); }); afterEach(() => { dialogMock.verify(); dialogMock.restore(); - stateMock.verify(); - stateMock.restore(); }); describe('ok()', () => { - it('calls $mdDialog.hide and $state.reload', () => { + it('calls $mdDialog.hide', () => { dialogMock.expects('hide'); - stateMock.expects('reload'); - controller.ok(); }); }); describe('close()', () => { - it('calls $mdDialog.cancel and $state.reload', () => { + it('calls $mdDialog.cancel', () => { dialogMock.expects('cancel'); - stateMock.expects('reload'); - controller.close(); }); });