Commit 3cc77262 authored by dev0tion's avatar dev0tion

Navigate with status message

parent 76cb8163
import { Component, OnInit } from '@angular/core'; import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router'; import { Router } from '@angular/router';
import { remote } from 'electron';
import { ApiService } from './shared/api/api.service'; import { ApiService } from './shared/api/api.service';
@Component({ @Component({
...@@ -13,9 +11,8 @@ import { ApiService } from './shared/api/api.service'; ...@@ -13,9 +11,8 @@ import { ApiService } from './shared/api/api.service';
export class AppComponent implements OnInit { export class AppComponent implements OnInit {
constructor(private router: Router, private apiService: ApiService) {} constructor(private router: Router, private apiService: ApiService) {}
private errorMessage: string; private errorMessage: any;
private response: any; private responseMessage: any;
private isConfigured: boolean = true;
ngOnInit() { ngOnInit() {
this.checkWalletStatus(); this.checkWalletStatus();
...@@ -24,22 +21,19 @@ export class AppComponent implements OnInit { ...@@ -24,22 +21,19 @@ export class AppComponent implements OnInit {
private checkWalletStatus(){ private checkWalletStatus(){
this.apiService.getWalletStatus() this.apiService.getWalletStatus()
.subscribe( .subscribe(
response => this.response = response, response => {
error => this.errorMessage = <any>error, if (response.status === 200) {
() => this.navigate() this.responseMessage = response;
this.router.navigate(['/login']);
}
},
error => {
this.errorMessage = <any>error;
if (error.status === 400 || error.status === 404) {
this.router.navigate(['/setup']);
console.log(this.errorMessage);
}
}
); );
} }
private navigate() {
if (this.response.success === "true") {
// remote.dialog.showMessageBox({message: remote.app.getPath('userData')})
this.router.navigate(['/login'])
} else {
this.router.navigate(['/setup'])
}
}
private hasWallet() {
return true;
}
} }
\ No newline at end of file
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