Skip to content
This repository has been archived by the owner on Apr 15, 2019. It is now read-only.

Commit

Permalink
Save selected network into a cookie
Browse files Browse the repository at this point in the history
  • Loading branch information
slaweet committed Jun 1, 2017
1 parent e4f662b commit f7f60c7
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/components/login/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,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);
Expand Down Expand Up @@ -72,6 +84,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}`);
Expand Down

0 comments on commit f7f60c7

Please sign in to comment.