Prepend network name to title when on testnet or liquid.

This commit is contained in:
softsimon 2020-04-04 21:47:05 +07:00
parent b082763438
commit d7a7095b8d
No known key found for this signature in database
GPG key ID: 488D7DCFB5A430D7
4 changed files with 17 additions and 6 deletions

View file

@ -60,7 +60,7 @@ export class AddressComponent implements OnInit, OnDestroy {
this.transactions = null; this.transactions = null;
document.body.scrollTo(0, 0); document.body.scrollTo(0, 0);
this.addressString = params.get('id') || ''; this.addressString = params.get('id') || '';
this.seoService.setTitle('Address: ' + this.addressString); this.seoService.setTitle('Address: ' + this.addressString, true);
return merge( return merge(
of(true), of(true),

View file

@ -59,7 +59,7 @@ export class BlockComponent implements OnInit, OnDestroy {
tap((block: Block) => { tap((block: Block) => {
this.block = block; this.block = block;
this.blockHeight = block.height; this.blockHeight = block.height;
this.seoService.setTitle('Block: #' + block.height + ': ' + block.id); this.seoService.setTitle('Block: #' + block.height + ': ' + block.id, true);
this.isLoadingBlock = false; this.isLoadingBlock = false;
this.setBlockSubsidy(); this.setBlockSubsidy();
if (block.reward) { if (block.reward) {

View file

@ -45,7 +45,7 @@ export class TransactionComponent implements OnInit, OnDestroy {
this.route.paramMap.pipe( this.route.paramMap.pipe(
switchMap((params: ParamMap) => { switchMap((params: ParamMap) => {
this.txId = params.get('id') || ''; this.txId = params.get('id') || '';
this.seoService.setTitle('Transaction: ' + this.txId); this.seoService.setTitle('Transaction: ' + this.txId, true);
this.error = undefined; this.error = undefined;
this.feeRating = undefined; this.feeRating = undefined;
this.isLoadingTx = true; this.isLoadingTx = true;

View file

@ -1,18 +1,29 @@
import { Injectable } from '@angular/core'; import { Injectable } from '@angular/core';
import { Title, Meta } from '@angular/platform-browser'; import { Title } from '@angular/platform-browser';
import { environment } from 'src/environments/environment';
@Injectable({ @Injectable({
providedIn: 'root' providedIn: 'root'
}) })
export class SeoService { export class SeoService {
network = environment.network;
defaultTitle = 'mempool - Bitcoin Explorer'; defaultTitle = 'mempool - Bitcoin Explorer';
constructor( constructor(
private titleService: Title, private titleService: Title,
) { } ) { }
setTitle(newTitle: string) { setTitle(newTitle: string, prependNetwork = false) {
this.titleService.setTitle(newTitle + ' - ' + this.defaultTitle); let networkName = '';
if (prependNetwork) {
if (this.network === 'liquid') {
networkName = 'Liquid ';
} else if (this.network === 'testnet') {
networkName = 'Testnet ';
}
}
this.titleService.setTitle(networkName + newTitle + ' - ' + this.defaultTitle);
} }
resetTitle() { resetTitle() {