Improved network switching.
This commit is contained in:
parent
e4d54ebb14
commit
756caf2c53
@ -11,6 +11,10 @@
|
|||||||
<div class="col-sm">
|
<div class="col-sm">
|
||||||
<table class="table table-borderless table-striped">
|
<table class="table table-borderless table-striped">
|
||||||
<tbody>
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td class="td-width">Hash</td>
|
||||||
|
<td><a [routerLink]="['/block/' | relativeUrl, block.id]" title="{{ block.id }}">{{ block.id | shortenString : 13 }}</a> <app-clipboard class="d-none d-sm-inline-block" [text]="block.id"></app-clipboard></td>
|
||||||
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td class="td-width">Timestamp</td>
|
<td class="td-width">Timestamp</td>
|
||||||
<td>
|
<td>
|
||||||
@ -20,10 +24,6 @@
|
|||||||
</div>
|
</div>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
|
||||||
<td>Transactions</td>
|
|
||||||
<td>{{ block.tx_count | number }}</td>
|
|
||||||
</tr>
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>Size</td>
|
<td>Size</td>
|
||||||
<td>{{ block.size | bytes: 2 }}</td>
|
<td>{{ block.size | bytes: 2 }}</td>
|
||||||
@ -38,10 +38,6 @@
|
|||||||
<div class="col-sm">
|
<div class="col-sm">
|
||||||
<table class="table table-borderless table-striped">
|
<table class="table table-borderless table-striped">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
|
||||||
<td class="td-width">Hash</td>
|
|
||||||
<td><a [routerLink]="['/block/' | relativeUrl, block.id]" title="{{ block.id }}">{{ block.id | shortenString : 13 }}</a> <app-clipboard class="d-none d-sm-inline-block" [text]="block.id"></app-clipboard></td>
|
|
||||||
</tr>
|
|
||||||
<tr *ngIf="block.medianFee !== undefined">
|
<tr *ngIf="block.medianFee !== undefined">
|
||||||
<td>Median fee</td>
|
<td>Median fee</td>
|
||||||
<td>~{{ block.medianFee | number:'1.0-0' }} sat/vB (<app-fiat [value]="block.medianFee * 250" digitsInfo="1.2-2"></app-fiat>)</td>
|
<td>~{{ block.medianFee | number:'1.0-0' }} sat/vB (<app-fiat [value]="block.medianFee * 250" digitsInfo="1.2-2"></app-fiat>)</td>
|
||||||
|
@ -38,30 +38,36 @@ export class StateService {
|
|||||||
constructor(
|
constructor(
|
||||||
private router: Router,
|
private router: Router,
|
||||||
) {
|
) {
|
||||||
|
this.setNetworkBasedonUrl(window.location.pathname);
|
||||||
|
|
||||||
this.router.events.subscribe((event) => {
|
this.router.events.subscribe((event) => {
|
||||||
if (event instanceof NavigationStart) {
|
if (event instanceof NavigationStart) {
|
||||||
switch (event.url.split('/')[1]) {
|
this.setNetworkBasedonUrl(event.url);
|
||||||
case 'liquid':
|
|
||||||
case 'liquid-tv':
|
|
||||||
if (this.network !== 'liquid') {
|
|
||||||
this.network = 'liquid';
|
|
||||||
this.networkChanged$.next('liquid');
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
case 'testnet':
|
|
||||||
case 'testnet-tv':
|
|
||||||
if (this.network !== 'testnet') {
|
|
||||||
this.network = 'testnet';
|
|
||||||
this.networkChanged$.next('testnet');
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
default:
|
|
||||||
if (this.network !== '') {
|
|
||||||
this.network = '';
|
|
||||||
this.networkChanged$.next('');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setNetworkBasedonUrl(url: string) {
|
||||||
|
switch (url.split('/')[1]) {
|
||||||
|
case 'liquid':
|
||||||
|
case 'liquid-tv':
|
||||||
|
if (this.network !== 'liquid') {
|
||||||
|
this.network = 'liquid';
|
||||||
|
this.networkChanged$.next('liquid');
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
case 'testnet':
|
||||||
|
case 'testnet-tv':
|
||||||
|
if (this.network !== 'testnet') {
|
||||||
|
this.network = 'testnet';
|
||||||
|
this.networkChanged$.next('testnet');
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
default:
|
||||||
|
if (this.network !== '') {
|
||||||
|
this.network = '';
|
||||||
|
this.networkChanged$.next('');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,14 +24,20 @@ export class WebsocketService {
|
|||||||
private onlineCheckTimeout: number;
|
private onlineCheckTimeout: number;
|
||||||
private onlineCheckTimeoutTwo: number;
|
private onlineCheckTimeoutTwo: number;
|
||||||
private subscription: Subscription;
|
private subscription: Subscription;
|
||||||
|
private network = '';
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
private stateService: StateService,
|
private stateService: StateService,
|
||||||
) {
|
) {
|
||||||
this.websocketSubject = webSocket<WebsocketResponse | any>(WEB_SOCKET_URL + '/' + this.stateService.network);
|
this.network = this.stateService.network;
|
||||||
|
this.websocketSubject = webSocket<WebsocketResponse | any>(WEB_SOCKET_URL + '/' + this.network);
|
||||||
this.startSubscription();
|
this.startSubscription();
|
||||||
|
|
||||||
this.stateService.networkChanged$.subscribe((network) => {
|
this.stateService.networkChanged$.subscribe((network) => {
|
||||||
|
if (network === this.network) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
this.network = network;
|
||||||
clearTimeout(this.onlineCheckTimeout);
|
clearTimeout(this.onlineCheckTimeout);
|
||||||
clearTimeout(this.onlineCheckTimeoutTwo);
|
clearTimeout(this.onlineCheckTimeoutTwo);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user