Commit 0b17ebee authored by Pieterjan Vanhoof's avatar Pieterjan Vanhoof Committed by GitHub

Merge pull request #260 from nopara73/recovery

Fix failing recovery message
parents f99a4a4f fe21fa84
...@@ -115,6 +115,7 @@ export class RecoverComponent implements OnInit { ...@@ -115,6 +115,7 @@ export class RecoverComponent implements OnInit {
} }
private recoverWallets(recoverWallet: WalletRecovery) { private recoverWallets(recoverWallet: WalletRecovery) {
let bitcoinErrorMessage = "";
this.apiService this.apiService
.recoverBitcoinWallet(recoverWallet) .recoverBitcoinWallet(recoverWallet)
.subscribe( .subscribe(
...@@ -122,6 +123,7 @@ export class RecoverComponent implements OnInit { ...@@ -122,6 +123,7 @@ export class RecoverComponent implements OnInit {
if (response.status >= 200 && response.status < 400) { if (response.status >= 200 && response.status < 400) {
//Bitcoin Wallet Recovered //Bitcoin Wallet Recovered
} }
this.recoverStratisWallet(recoverWallet, bitcoinErrorMessage);
}, },
error => { error => {
this.isRecovering = false; this.isRecovering = false;
...@@ -133,16 +135,17 @@ export class RecoverComponent implements OnInit { ...@@ -133,16 +135,17 @@ export class RecoverComponent implements OnInit {
console.log(error); console.log(error);
} }
else { else {
alert(error.json().errors[0].message); bitcoinErrorMessage = error.json().errors[0].message;
} }
} }
}, this.recoverStratisWallet(recoverWallet, bitcoinErrorMessage);
() => this.recoverStratisWallet(recoverWallet) }
) )
; ;
} }
private recoverStratisWallet(recoverWallet: WalletRecovery){ private recoverStratisWallet(recoverWallet: WalletRecovery, bitcoinErrorMessage: string){
let stratisErrorMessage = "";
this.apiService this.apiService
.recoverStratisWallet(recoverWallet) .recoverStratisWallet(recoverWallet)
.subscribe( .subscribe(
...@@ -151,6 +154,7 @@ export class RecoverComponent implements OnInit { ...@@ -151,6 +154,7 @@ export class RecoverComponent implements OnInit {
alert("Your wallet has been recovered. \nYou will be redirected to the decryption page."); alert("Your wallet has been recovered. \nYou will be redirected to the decryption page.");
this.router.navigate(['']) this.router.navigate([''])
} }
this.AlertIfNeeded(bitcoinErrorMessage, stratisErrorMessage);
}, },
error => { error => {
this.isRecovering = false; this.isRecovering = false;
...@@ -162,11 +166,19 @@ export class RecoverComponent implements OnInit { ...@@ -162,11 +166,19 @@ export class RecoverComponent implements OnInit {
console.log(error); console.log(error);
} }
else { else {
alert(error.json().errors[0].message); stratisErrorMessage = error.json().errors[0].message;
} }
} }
this.AlertIfNeeded(bitcoinErrorMessage, stratisErrorMessage);
} }
) )
; ;
} }
private AlertIfNeeded(bitcoinErrorMessage: string, stratisErrorMessage: string) {
if(bitcoinErrorMessage !== "" || stratisErrorMessage !== "") {
let errorMessage = "Bitcoin wallet recovery:\n" + bitcoinErrorMessage + "\n\nStratis wallet recovery:\n" + stratisErrorMessage;
alert(errorMessage);
}
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment